[Tutor] What's the invalid syntax? Code supplied
Nathan Pinno
falcon3166 at hotmail.com
Fri Aug 5 22:56:44 CEST 2005
Hi all,
What's the invalid syntax? Here is the code:
import random
hand = {
'0' : ["Ace"]
'1' : ["Two"]
'2' : ["Three"]
'3' : ["Four"]
'4' : ["Five"]
'5' : ["Six"]
'6' : ["Seven"]
'7' : ["Eight"]
'8' : ["Nine"]
'9' : ["Ten"]
'10' : ["Jack"]
'11' : ["Queen"]
'12' : ["King"]
}
types = {
'0' : ["Diamonds"]
'1' : ["Hearts"]
'2' : ["Spades"]
'3' : ["Clubs"]
}
playercards = [a,b,c,d,e]
t = [t1,t2,t3,t4,t5]
def menu():
print "1. Deal a hand"
print "2. Exit"
def option():
return int(raw_input("Option: "))
def deal():
playercards = random.choice(13)
t = random.choice(4)
print "The Five Card Dealer"
print "By Nathan Pinno"
while 1:
menu()
opt = option()
while opt == 1:
deal()
for index in range(len(playercards)):
if index == 0:
index = hand['0']
if index == 1:
index = hand['1']
if index == 2:
index = hand['2']
if index == 3:
index = hand['3']
if index == 4:
index = hand['4']
if index == 5:
index = hand['5']
if index == 6:
index = hand['6']
if index == 7:
index = hand['7']
if index == 8:
index = hand['8']
if index == 9:
index = hand['9']
if index == 10:
index = hand['10']
if index == 11:
index = hand['11']
if index == 12:
index = hand['12']
for indice in range(len(t)):
if indice == 0:
indice = types['0']
if indice == 1:
indice = types['1']
if indice == 2:
indice = types['2']
if indice == 3:
indice = types['3']
print a," of ",t1, b," of ",t2, c," of ",t3, d," of ",t4, e," of ",t5
while opt == 2:
break
print "Goodbye."
If it helps it highlighted the ' after 1 in the hand dictionary.
Thanks,
Nathan Pinno,
Crew, Camrose McDonalds and owner/operator of Zoffee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050805/e288897b/attachment.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Pinno, Nathan Paul.vcf
Type: text/x-vcard
Size: 783 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20050805/e288897b/PinnoNathanPaul.vcf
More information about the Tutor
mailing list