[Tutor] Why do I get an "unvalid syntax" on the print line for number1

Mark Lawrence breamoreboy at yahoo.co.uk
Tue Apr 23 20:24:35 CEST 2013


On 20/04/2013 21:33, Pat Collins wrote:
> Any help appreciated.
>
>
> #!/usr/bin/env python
> """
> number.py Demonstrates collecting a number from the user.
> """
>
> number_string1 = float(input("Give me a number: "))
> number1 = (number_string1)

Why not number1 = float(input("Give me a number: ")) ?

>
> number_string2 = float(input("Give me another number: "))
> number2 = (number_string2)

Ditto.

>
> print number1, "times", number, "+", number1 * number2
>

You're using Python 3 so print needs parenthesis as it's a function and 
not a statement.


-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence



More information about the Tutor mailing list