[Tutor] What's the invalid syntax?

Alan Gauld alan.gauld at freenet.co.uk
Thu Apr 6 09:40:02 CEST 2006


> What's the invalid syntax in the following code? I tried figuring it out 
> by
> myself, and I couldn't.
>
> # Inspired by Programming and Problem Solving with Java, 1st ed., question
> def date():
>    int year
>    year = int(raw_input("Year please: "))

> The editor highlights the word year in the line:
>
> int year

That'd be because int year is invalid syntax in Python.

You don't need to decalre variables prior to use in Python
as you do in Java. Also names in Python are not typed.

Alan G




More information about the Tutor mailing list