[Tutor] Issue w/ string input "for", "not", "while", "else" etc.

Peter Otten __peter__ at web.de
Tue Nov 26 17:49:48 CET 2013


Rafael Knuth wrote:

> Hej there,
> 
> simple issue I couldn't find a solution for:
> 
> 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 and changes the
> input's color to the corresponding command. The program runs without
> any further issues, but I was wondering: How can I make sure Python
> "understands" that the user input is nothing else but a string? I
> tried to fix that by changing input("What is your name?") to
> input(str("What is your name?)) but that didn't work.
> 
> Thanks in advance,

Are you running the program inside idle? The (in this case unwanted) syntax 
highlighting is a feature of idle's shell. 

You could try and make a feature request on <http://bugs.python.org> for 
smarter colouring.




More information about the Tutor mailing list