[Tutor] What's the invalid syntax? Code supplied
Terry Carroll
carroll at tjc.com
Sat Aug 6 01:40:08 CEST 2005
On Fri, 5 Aug 2005, Nathan Pinno wrote:
> What's the invalid syntax? Here is the code:
Nathan,
My method when encountering a syntax error like this is to look at the
part of my code that's generating the syntax error, and see what structure
or function it's using. Then find a program segment that does the
same thing in a working program or tutorial. Now that I've
written a good number of working programs, I can usually find
working examples in my own programs, but if not, I hit a python
book.
I think you'll find this more efficient than simply posting the error
message and code to the Tutor list and asking for help; save the Tutor
list for the really challenging problems. You'll find you learn a lot
more by taking a good whack at it yourself, first.
In your case you've already indicated the error is in this code:
> 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"]
> }
You're trying to initialize a dictionary. So go find some examples of
initializing a dictionary that work, compare them to your code, and see if
you can see what's different about your code.
Good luck!
More information about the Tutor
mailing list