Hi all,
I am new Phython user and started using Python 2.7 just a couple days ago. I have written this code which is working, But when user put in correct code loop is not breaking ?? just wondering if it could be improved and what book would you recommend for Python 2.7 or 3? and do you know when Python 3 will be available? also hear about something called gygame (I think) which should work with python but I could not get this work with Python ! any help here would greatful recieved..
INPUT TEST>>>PYTHON 2.7: DATE OF CODING 11.12.2010
#set up verible for shopping
item =
price = [10, 50, 35, 75]
gold=100
# display items for sale
print ' I have the following items for sale'
print
print item[0] + ' at ' + str(price[0]) + ' Gold bits'
print
print item[1] + ' at ' + str(price[1]) + ' Gold bits'
print
print item[2] + ' at ' + str(price[2]) + ' Gold bits'
print
print item[3] + ' at ' + str(price[3]) + ' Gold bits'
#buying a item and deducting money
while True:
input = raw_input("\nPress, D, S, B or A to purchuse the item or Z to leave: ")
if input == 'd' or input =='D':
print "\nYou broght a " + item[0] + ' at ' + str(price[0])
elif input =='s' or input =='S':
print "\nYou broght a " + item[1] + ' at ' + str(price[1])
elif input =='b' or input =='B':
print "\nYou broght a " + item[2] + ' at ' + str(price[2])
elif input =='a' or input =='A':
print "\nYou broght a " + item[3] + ' at ' + str(price[3])
elif input =='z' or input == 'Z':
print '\nBye for now'
break;
else:
print '\nYou need to Enter D, S, B, A OR Z. TRY AGAIN!'
print "\nYou have Gold " + str(gold-price[0]) + ' bits left'
Thanks for you time
Stephen