i need know why nothing comes on python when type code.
is because of def myscript()?
i new both python , website - stackoverflow.
import time def myscript(): print("what want buy? have currently") print ("you have choice between following , may buy one:") time.sleep(1) pistol = 20 print("a pistol 20 coins") time.sleep(1) costfuel = 10 print("15 fuel 10 coins") time.sleep(1) shotgun = 40 print("a shotgun 40 coins") time.sleep(1) costoxygen = 10 print("10 oxygen 10 coins") time.sleep(1) costlife = 50 print("or 5 life 50 coins") time.sleep(1) choose = input("you may choose of following want - please type in e.g pistol. ") if choose == "pistol": while coins < pistol: print ("you cannot buy not have enough money.") time.sleep(4) myscript() else: print ("thank purchasing pistol! have",coins,"coins remaining") elif choose == "costfuel": while coins < costfuel: print ("you cannot buy not have enough money.") time.sleep(4) myscript() else: print ("thank purchasing fuel! have",fuel,"fuel remaining and",coins,"coins remaining.") else: while coins < shotgun: print ("you cannot buy not have enough money.") time.sleep(4) myscript() else: print ("thank purchasing shotgun! have",coins,"coins remaining") myscript()
myscript() tabbed wrong, part of function definition. import time looks off.
here corrected code. see difference?
import time def myscript(): print("what want buy? have currently") print ("you have choice between following , may buy one:") time.sleep(1) pistol = 20 print("a pistol 20 coins") time.sleep(1) costfuel = 10 print("15 fuel 10 coins") time.sleep(1) shotgun = 40 print("a shotgun 40 coins") time.sleep(1) costoxygen = 10 print("10 oxygen 10 coins") time.sleep(1) costlife = 50 print("or 5 life 50 coins") time.sleep(1) choose = input("you may choose of following want - please type in e.g pistol. ") if choose == "pistol": while coins < pistol: print ("you cannot buy not have enough money.") time.sleep(4) myscript() else: print ("thank purchasing pistol! have",coins,"coins remaining") elif choose == "costfuel": while coins < costfuel: print ("you cannot buy not have enough money.") time.sleep(4) myscript() else: print ("thank purchasing fuel! have",fuel,"fuel remaining and",coins,"coins remaining.") else: while coins < shotgun: print ("you cannot buy not have enough money.") time.sleep(4) myscript() else: print ("thank purchasing shotgun! have",coins,"coins remaining") myscript()
Comments
Post a Comment