John Joseph said unto the world upon 31/12/05 02:09 AM:
> Hi
> I am trying out learning python , using the book
> “Python Programming for the absolute beginner “ by
> Michael Dawson
> I get
> File "page114.py", line 12
> inventory = ("Sword","Armor","Shield","Healing
> Potion")
> ^
> SyntaxError: invalid syntax
>
> when I run the program which I copied from the text ,
> tried a lot to find the reason , I thought of sending
> it to the list , so that I get feed back on where I
> had gone worng
Hi John,
sometimes the syntax error indicator isn't quite pointing to the
problem. In your case, the place it points was where Python worked out
there was a problem, but the difficulty with your code is several
lines up (I've indicated where in the code below). Once this happens a
few times, you will get used to looking back for unclosed brackets.
HTH,
Brian vdB
> **********************************************************
> inventory()
>
> # treat the tuple as condition
>
> if not inventory:
> print "U are empty Handed."
>
> raw_input("\nPress the enter key to continue."
^
|
|
You need to close the raw_input call. Add a ')' -
> #Create a tuple with some items
>
> inventory = ("Sword","Armor","Shield","Healing
> Potion")
>
> #print the tuple
>
> print "\n The Tuple inventory is: \n", inventory
>
>
> # print each element in the tuple
>
> print "\nYour Items:"
> for item in inventory:
> print item,
>
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor