I've been working on a project recently to refresh on my Python, and I need to set a variable to a name.
name = raw_input("What is your name?")
Is what I have so far, and I can't get it to set the variable (name) to be any word. When I put print (name)
in the line after, it comes up with an error. How do I set the variable to anything that the player inputs?
Asked
Active
Viewed 85 times
1

Oliver
- 11
- 1
-
3if you are using python 3, `input()` is all you need – MooingRawr Sep 01 '17 at 13:22
-
4Possible duplicate of [How do I use raw\_input in Python 3](https://stackoverflow.com/questions/954834/how-do-i-use-raw-input-in-python-3) – Chris_Rands Sep 01 '17 at 13:24
1 Answers
0
If you are using python version 3.x
then for raw_input() you will got error saying NameError: name 'raw_input' is not defined
. For python3.X you can use name = input("What is your name?")
while what you are doing will run in python2.X
perfectly.

Vineet Jain
- 1,515
- 4
- 21
- 31