[PyAR2] .upper()

Chris Nestrud ccn at panix.com
Sat Aug 6 18:18:41 CEST 2011


Try using raw_input instead of input. The input function expects a valid
Python expression. The raw_input function is for general input. See
http://docs.python.org/library/functions.html

Chris

On Sat, Aug 06, 2011 at 07:40:17AM -0500, Daniel Veazey wrote:
> Almost a total noob here, getting stumped. Using Python 2.7.1+. Here is my
> code:
> 
> while True:
>     reply = input("Enter text: ")
>     if reply == 'stop': break
>     print(reply.upper())
> 
> It's supposed to just take the text that the user has entered and print it
> in uppercase, unless the user types 'stop.'
> 
> But I get errors when I run it:
> 
> Enter text: word
> Traceback (most recent call last):
>   File "upper.py", line 2, in <module>
>     reply = input("Enter text: ")
>   File "<string>", line 1, in <module>
> NameError: name 'word' is not defined
> 
> Enter text: stop
> Traceback (most recent call last):
>   File "upper.py", line 2, in <module>
>     reply = input("Enter text: ")
>   File "<string>", line 1, in <module>
> NameError: name 'stop' is not defined
> 
> Enter text: two words
> Traceback (most recent call last):
>   File "upper.py", line 2, in <module>
>     reply = input("Enter text: ")
>   File "<string>", line 1
>     two words
>             ^
> SyntaxError: unexpected EOF while parsing
> 
> Any tips?

> _______________________________________________
> PyAR2 mailing list
> PyAR2 at python.org
> http://mail.python.org/mailman/listinfo/pyar2



More information about the PyAR2 mailing list