Follow

@Absinthe
Puluhan = {9 : "Ninety",8 : "Eighty",7 : "Seventy",6 : "Sixty",5 : "Fifty",4 : "Forty",3 : "Thirty",2 : "Twenty",1 : "",0 : "",}
Belasan = {9: "Nineteen", 8: "Eighteen", 7:"Seventeen",6: "Sixteen", 5: "Fifteen", 4:"Fourteen",3:"Thirteen",2:"Twelve", 1: "Eleven",0:"Ten"}
Satuan = {9 : "-Nine",8 : "-Eight",7 : "-Seven",6 : "-Six",5 : "-Five",4 : "-Four",3 : "-Three",2 : "-Two",1 : "-One",0 : "",}
SatuanS = {10:"Ten", 9 : "Nine",8 : "Eight",7 : "Seven",6 : "Six",5 : "Five",4 : "Four",3 : "Three",2 : "Two",1 : "One",0 : "",}
f = 9
n = 9
h = 9
while f > 1 :
g = 9
while g > -1 :
if g == 0 and f != 2:
o = Puluhan[f]+Satuan[g] + " bottle of beers on the wall.\n"+Puluhan[f]+ Satuan[g]+" bottles of beer. Take one down, pass it around...\n"+Puluhan[f-1]+Satuan[9]+" bottles of beer on the wall."
else :
if g > 1:
o = Puluhan [f]+Satuan[g] + " bottle of beers on the wall. \n" + Puluhan [f]+Satuan[g]+ " bottles of beer. Take one down, pass it around...\n"+Puluhan[f]+Satuan[g-1]+" bottles of beer on the wall."
elif g == 1 :
o = Puluhan [f]+Satuan[g] + " bottle of beers on the wall. \n" + Puluhan [f]+Satuan[g]+ " bottles of beer. Take one down, pass it around...\n"+Puluhan[f]+" bottles of beer on the wall."
g = g-1
print o
if f == 2 and g == 0:
break
else :
continue
f = f-1
while f > -1 :
g = 9
while g >0 and f > 0:
o = Belasan[g] + " bottle of beers on the wall.\n"+Belasan[g]+" bottles of beer. Take one down, pass it around...\n"+Belasan[g-1]+" bottles of beer on the wall."
print o
g = g -1
g = 10
while g > 0 and f < 1:
if g == 1:
o = SatuanS[g] + " bottle of beers on the wall.\n"+SatuanS[g]+" bottles of beer. Take one down, pass it around...\n""No bottles of beer."
else :
o = SatuanS[g] + " bottle of beers on the wall.\n"+SatuanS[g]+" bottles of beer. Take one down, pass it around...\n"+SatuanS[g-1]+" bottles of beer on the wall."
print o
g = g -1
f = f-1
print "Done"

A newbie with python. Having this challenge taught me how I could play with loop. Funny, how I thought to use for but then realize while is a lot more fitting.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves. A STEM-oriented instance.

An inclusive free speech instance.
All cultures and opinions welcome.
Explicit hate speech and harassment strictly forbidden.
We federate with all servers: we don't block any servers.