On 23/12/14 18:27, stuart kurutac wrote:
Hello all,
I've come across an invalid syntax error on 2 occassoins now.
> For the life of me I can't see what's wrong.
finish = (int(input("Finish: "))
print("word[", start, ":", finish, "] is", end=" ")
When I run this through the terminal in linux using python3 I get the following:
File "pizza_slicer.py", line 32
print("word[", start, ":", finish, "] is", end=" ")
^
SyntaxError: invalid syntax
Adam has told you what is wrong but, for reference, Python points to the
"wrong" line because, with the missing parens, it sees your code
as:
finish = (int(input("Finish: ")) print("word[", ....
And its illegal to have a print() immediately after an int() call.
So it flags the print statement as illegal.
The lesson is that when you get a syntax error thats not obvious check
the line or two above as well. Unbalanced quotes or parens/brackets are
often the cause.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor