[Tutor] Issue w/ string input "for", "not", "while", "else" etc.
Alan Gauld
alan.gauld at btinternet.com
Tue Nov 26 17:22:21 CET 2013
On 26/11/13 16:15, Rafael Knuth wrote:
> YourName = input(str("What is your name?"))
> print("Hello", YourName)
>
> When executing the program, in case the user input is "for", "not",
> "True", "while" Python interprets that as a command
Sounds like you are using Python v2.
You need to yuse raw_input() instead of input().
In Python v3 the old input was removed and raw_input
renamed to input()
Are you by any chance reading a v3 tutorial but using v2?
BTW the str() in
> YourName = input(str("What is your name?"))
does nothing since "What is your name?" is already a string
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list