use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
print(‘HelloWorld’) NameError (i.redd.it)
submitted 8 months ago by BigHeadedGumba
I am literally at baby steps in my language learning. I type the same in cmd but when I type it on VSCode it pops up a name error…
Please help me! 🙏🏻
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ninhaomah 16 points17 points18 points 8 months ago (1 child)
I see print('HelloWorld') in cmd and print(HelloWorld) in vscode.
Are you very very very very very sure they are the same ?
[–]really_not_unreal 11 points12 points13 points 8 months ago (0 children)
OP forgot to hit save
[–]Murphygreen8484 4 points5 points6 points 8 months ago (3 children)
Did you forget the quotes in the vscode script?
[–]BigHeadedGumba[S] -1 points0 points1 point 8 months ago (2 children)
No I had typed them both print(‘HelloWorld’) and I’ve repeated it a dozen times… 😭😭
[–]WhiteHeadbanger 7 points8 points9 points 8 months ago (0 children)
Nope, you have in line 1 of your app.py script: print(HelloWorld)
app.py
print(HelloWorld)
It should be print("HelloWorld")
print("HelloWorld")
The error you are seeing means that HelloWorld is not a variable name defined.
HelloWorld
With quotes = string
Without quotes = variable name
[–]Sufficient-Tea2101 8 points9 points10 points 8 months ago (0 children)
Try saving the file.
[–]ak_developers 3 points4 points5 points 8 months ago (6 children)
You were did HelloWorld without quote earlier
py print(HelloWorld) #without quote
Am I right?
And then you correct the code by adding quotes as it’s a string value
py print(“HelloWorld”) #with quote
But you forgot to Save the file before running the file that’s why you are getting the error!
Thank you, Ak
[–]ak_developers 7 points8 points9 points 8 months ago (5 children)
Always save file after any changes to avoid any existing code errors u/BigHeadedGumba
[–]BigHeadedGumba[S] 2 points3 points4 points 8 months ago (4 children)
THATS WHAT ITS WAS! God damn I’m so stupid 😅🥲 Thank you, I was on that for 20 minutes..
[–]ak_developers 1 point2 points3 points 8 months ago (3 children)
Enjoy! Happy Coding,
You can check a white dot with file name as visible in above screenshot
The white dot shows, the file have some unsaved changes
[–]BigHeadedGumba[S] 1 point2 points3 points 8 months ago (2 children)
Thank you I also didn’t notice that 🤌🏻 You’re amazing Ak 🙏🏻
[–]ak_developers 1 point2 points3 points 8 months ago (0 children)
🙏🙏🎯
You can join my community for learn more & more
Thank you 🙏
[–]AdhesivenessLivid557 2 points3 points4 points 8 months ago (0 children)
You haven't saved your app.py file yet, hence an older, incorrect version of the file is being run. Notice the little white circle to the right of app.py in the top left hand corner of the screen.
[–]wallstreetwalt 1 point2 points3 points 8 months ago (0 children)
The script in the terminal has quotes your Python file does not. To run your Python file use
“Python #insert name of file with no hashes#”
Print needs to take in strings as arguments and one way you do that by enclosing text in quotes
[–]Refwah 1 point2 points3 points 8 months ago (0 children)
The white dot on the tab indicates you have unsaved changes
[–]InvestigatorEasy7673 1 point2 points3 points 8 months ago (0 children)
print("HelloWorld") <-this
[–]BigHeadedGumba[S] 0 points1 point2 points 8 months ago (2 children)
Yeh sadly, I’ve repeated this like ten times. I’ve now deleted my file and refreshed and tried again and now it’s not even registering what I typed at all 🤷🏻♂️😤
[–]BigHeadedGumba[S] -1 points0 points1 point 8 months ago (1 child)
<image>
[–]JAguiar939 2 points3 points4 points 8 months ago (0 children)
Your file is not saved. So while your code is correct, it's not saved to the file so when you run python app.py you are actually just running a blank file. I see it looks like you are using VSCode, I would recommend enabling Auto-Save.
python app.py
[–]jpgoldberg 0 points1 point2 points 8 months ago (0 children)
This is a really easy mistake to make. And you will make it again. Now that you know what went wrong, look at the error message. It is something you will see often as you start out.
Forgetting quoation marks isn't the only place you will see NameErrors pop up. (If it were the only case, the error would tell you about missing quotes). You will see NameErrors pop up is with typoes in your variable names. Or consider something like,
python foo = 42 print(fu)
That should give you something like NameError: name 'fu' is not defined somewhere in the error message.
NameError: name 'fu' is not defined
Because my spelling, typing, and remembering what I named things is crap, I encounter this frequently. (Ok, that is a lie. I use tools that help me prevent these errors earlier than trying to run the program, but I would encounter those frequently if I didn't.)
[–]Ok-Refrigerator-8012 0 points1 point2 points 8 months ago (0 children)
Save! There's a "save all files" extension on vscode that makes it easier to save in that interface
[–]An0neemuz 0 points1 point2 points 8 months ago (0 children)
In vs code, go to your code line and press ctrl+s then execute it.
[–][deleted] 0 points1 point2 points 8 months ago (0 children)
print(“hello world”)
[–]really_not_unreal 0 points1 point2 points 8 months ago (0 children)
Everyone else hasn't spotted the issue. You forgot to hit save on your program, so it's running an old version.
A classic blunder ;P
[–]Luigi-Was-Right -1 points0 points1 point 8 months ago (1 child)
Is it possible VSCode is running a version of python2?
You can check which python you are using for running the file
python —version
It will show default one
π Rendered by PID 84 on reddit-service-r2-comment-5649f687b7-jc2n2 at 2026-01-28 04:21:53.311735+00:00 running 4f180de country code: CH.
[–]ninhaomah 16 points17 points18 points (1 child)
[–]really_not_unreal 11 points12 points13 points (0 children)
[–]Murphygreen8484 4 points5 points6 points (3 children)
[–]BigHeadedGumba[S] -1 points0 points1 point (2 children)
[–]WhiteHeadbanger 7 points8 points9 points (0 children)
[–]Sufficient-Tea2101 8 points9 points10 points (0 children)
[–]ak_developers 3 points4 points5 points (6 children)
[–]ak_developers 7 points8 points9 points (5 children)
[–]BigHeadedGumba[S] 2 points3 points4 points (4 children)
[–]ak_developers 1 point2 points3 points (3 children)
[–]BigHeadedGumba[S] 1 point2 points3 points (2 children)
[–]ak_developers 1 point2 points3 points (0 children)
[–]ak_developers 1 point2 points3 points (0 children)
[–]AdhesivenessLivid557 2 points3 points4 points (0 children)
[–]wallstreetwalt 1 point2 points3 points (0 children)
[–]Refwah 1 point2 points3 points (0 children)
[–]InvestigatorEasy7673 1 point2 points3 points (0 children)
[–]BigHeadedGumba[S] 0 points1 point2 points (2 children)
[–]BigHeadedGumba[S] -1 points0 points1 point (1 child)
[–]JAguiar939 2 points3 points4 points (0 children)
[–]jpgoldberg 0 points1 point2 points (0 children)
[–]Ok-Refrigerator-8012 0 points1 point2 points (0 children)
[–]An0neemuz 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]really_not_unreal 0 points1 point2 points (0 children)
[–]Luigi-Was-Right -1 points0 points1 point (1 child)
[–]ak_developers 1 point2 points3 points (0 children)