Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner question NameError
#1
I i have this two lines:

name = input("Enter your name: ")
print("Hello " + name + "!")
Here is what I got:
Error:
Enter your name: jason Traceback (most recent call last): File "C:/Users/XXX/PycharmProjects/XXX/XXX_app.py", line 1, in <module> name = input("Enter your name: ") File "<string>", line 1, in <module> NameError: name 'jason' is not defined Process finished with exit code 1
buran write Aug-13-2021, 05:19 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
I think you are using python 2.7. Befote python 3 the input function tried to evaluate what you typed. To enter a string you used raw_input.
Reply
#3
Check https://python-forum.io/thread-11439.html
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
Newbie here. I tried your code in Pycharm 2021.2 No problem, see below.

Output:
Enter your name: James Bond Hello James Bond!
Reply
#5
(Aug-13-2021, 05:03 AM)plumberpy Wrote: I tried your code in Pycharm 2021.2
It depends on Python version, not on PyCharm/IDE version. They use python2, you obviously use python3
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(Aug-13-2021, 05:19 AM)buran Wrote:
(Aug-13-2021, 05:03 AM)plumberpy Wrote: I tried your code in Pycharm 2021.2
It depends on Python version, not on PyCharm/IDE version. They use python2, you obviously use python3

Oh yes. I forgot about that. Thanks.
Reply
#7
Thank you. I have updated my Python version. It's resolved.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Very Beginner question on simple variables Harvy 1 199 Apr-12-2024, 12:03 AM
Last Post: deanhystad
  A simple "If...Else" question from a beginner Serena2022 6 1,758 Jul-11-2022, 05:59 AM
Last Post: Serena2022
Question Beginner Boolean question [Guessing game] TKB 4 2,342 Mar-22-2022, 05:34 PM
Last Post: deanhystad
  Question about NameError Than999 2 1,781 Dec-10-2021, 03:54 PM
Last Post: Than999
  Beginner question - storing values cybertron2 4 3,260 Mar-09-2021, 04:21 AM
Last Post: deanhystad
  beginner question about lists and functions sudonym3 5 2,771 Oct-17-2020, 12:31 AM
Last Post: perfringo
  beginner question ___ 1 1,755 Jul-12-2020, 08:12 AM
Last Post: Gribouillis
  Beginner question: lxml's findall in an xml namespace aecklers 0 2,927 Jan-22-2020, 10:53 AM
Last Post: aecklers
  Super easy beginner question AkulaLA 3 3,298 Nov-07-2019, 03:42 AM
Last Post: Larz60+
  NameError: NameError: global name 'BPLInstruction' is not defined colt 7 4,420 Oct-27-2019, 07:49 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020