Carrie Pett
Carrie Pett

Reputation: 31

What's a substitute for raw_input() in 3.6?

e=input('what's your name?')

print('so you %s, %s, %s.' % (e,l,x))

I want to create a program where I'm required to answer my questions, but using input() just returns [so you , , .].

Upvotes: 2

Views: 14863

Answers (1)

flen
flen

Reputation: 2386

OK, I'm guessing you're talking about Python 3.6.

First mistake:

 e=input('what's your name?') #notice how you're using too many "'"

Correct:

 e=input("what's your name?")

Second mistake:

print('so you %s, %s, %s.' % (e,l,x)) 
#you did not specify l and x, so Python will throw an error

Correct:

Declare and assign values to the "l" and "x" variables before using them.
Just make an input like you did to "e", for example:

l=input("what's your L?")


In Python 3 there are no raw_inputs because all inputs are raw_inputs.
It took away Python's 2 regular input because it was too problematic. So Python's 3 input == Python's 2 raw_input.

To use Python's 2 regular input in Python 3, use eval(input()). For more information, see: http://docs.python.org/dev/py3k/whatsnew/3.0.html

Upvotes: 11

Related Questions