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

Chris “Kwpolska” Warrick kwpolska at gmail.com
Tue Apr 23 20:19:28 CEST 2013


On Sat, Apr 20, 2013 at 10:33 PM, Pat Collins <collins.pat0108 at gmail.com> 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)
>
> number_string2 = float(input("Give me another number: "))
> number2 = (number_string2)
>
> print number1, "times", number, "+", number1 * number2
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

You are probably using Python 3 (check with `python --version`).  In
this version, print is a function.  You need to do the following
instead:

print(number1, "times", number, "+", number1 * number2)

--
Kwpolska <http://kwpolska.tk> | GPG KEY: 5EAAEA16
stop html mail                | always bottom-post
http://asciiribbon.org        | http://caliburn.nl/topposting.html


More information about the Tutor mailing list