[Tutor] Beginning String Problems
Alan Gauld
alan.gauld at yahoo.co.uk
Wed Jan 1 20:17:01 EST 2020
On 01/01/2020 23:22, William Dickey wrote:
> first_name = str(input("Please enter your first name: "))
> I enter william and I get this error:
>
> Traceback (most recent call):
> File "C:\xxx\xxx\xxx\xxx", line 3, in <module>
> first_name = str(input("Please enter your first name: "))
> File "<string>", line 1, in <module>
> NameError: name 'william' is not defined
>
> I am using Windows 10 64 bit, Atom text editor, Python 3.4.
How are you running the code?
The error you get is what I would expect if you were using Python v2.
If you are just typing
python script.py
Then you may be picking up a default v2 install of Python.
Try changing the command to
python3 script.py
There is also a tool called py.exe, which is supposed to help
with this kind of thing on Windows, but I've never used it
so don't know how it works...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list