Ok guys can anyone explain about the error I'm getting for the following code : | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Ok guys can anyone explain about the error I'm getting for the following code :

anyname=input ("What's ur name? ") print("Welcome aboard Mr", anyname, "to our society" ) Gave input as ashish And the error is Traceback (most recent call last): File "./a.py", line 2, in <module> anyname=input("Whats ur name sir?") File "<string>", line 1, in <module> NameError: name 'ashish' is not defined

16th Apr 2018, 8:30 AM
Ashish Kumar
Ashish Kumar - avatar
12 Answers
+ 1
try : python3 a.py
16th Apr 2018, 8:56 AM
Markus Kaleton
Markus Kaleton - avatar
+ 1
Oh sorry I found the error.. My default python is 2.7 While compiling I tried now as python3.6./a.py it worked fine now
16th Apr 2018, 8:59 AM
Ashish Kumar
Ashish Kumar - avatar
+ 1
Thank you all :)
16th Apr 2018, 9:00 AM
Ashish Kumar
Ashish Kumar - avatar
0
it works just fine. no errors
16th Apr 2018, 8:39 AM
Markus Kaleton
Markus Kaleton - avatar
0
I tried in the solo learn's terminal it works fine. But here in Linux it's showing this error
16th Apr 2018, 8:40 AM
Ashish Kumar
Ashish Kumar - avatar
0
Is there any way I can post a screenshot here?
16th Apr 2018, 8:41 AM
Ashish Kumar
Ashish Kumar - avatar
0
That code works fine on PC as well. Check that you have it in that format on your computer as well. You should be able to post links here as far as i know
16th Apr 2018, 8:43 AM
Markus Kaleton
Markus Kaleton - avatar
0
Check out the screenshot https://imgur.com/a/WARsF
16th Apr 2018, 8:50 AM
Ashish Kumar
Ashish Kumar - avatar
0
Which version of python are you using?
16th Apr 2018, 8:55 AM
Danigamy
Danigamy - avatar
0
3.6
16th Apr 2018, 8:55 AM
Ashish Kumar
Ashish Kumar - avatar
0
Yes try that.
16th Apr 2018, 8:57 AM
Danigamy
Danigamy - avatar
0
You are welcome!
16th Apr 2018, 9:01 AM
Danigamy
Danigamy - avatar