Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (12.7k points)

I want to get a string from a user, and then manipulate it.

testVar = input("Ask user for something.")

Can testVar be made a string without having the user to type his response in quotes? i.e. "Hello" vs. Hello

If the user types in Hello, the following error message appears:

NameError: name 'Hello' is not defined

1 Answer

0 votes
by (26.4k points)

Instead of using input(), you can use raw_input().

testVar = raw_input("Ask user for something.")

input() really assesses the input as Python code. I recommend never utilize it. raw_input() restores/returns the verbatim string entered by the user.

Are you pretty much interested to learn Python in detail? Register for the Python training course to gain more knowledge.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.6k users

Browse Categories

...