When using Python3, and doing something as simple as
x=input("Enter your name: ")
print (x)
and trying to run it, the user would have to input their name as "Steve" rather than just Steve.
Is there a way around having to input with quotations?
I think you're mistaken. In Python 3, you don't need quotation marks:
localhost-2:~ $ python3.3
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = input("Enter your name:")
Enter your name:Steve
>>> x
'Steve'
You would in the olden days of Python 2, because input basically evals what you give it:
>>> x = input("Enter your name:")
Enter your name:Steve
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
NameError: name 'Steve' is not defined
>>> x = input("Enter your name:")
Enter your name:"Steve"
>>> x
'Steve'
and so you'd use raw_input instead:
>>> x = raw_input("Enter your name:")
Enter your name:Steve
>>> x
'Steve'
But in Python 3, input is what raw_input used to be, and so no quotation marks are necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With