How do I run a piece of code in the Terminal despite leading zeros?

Dear Python community,

thank you in advance for your help. I am new to programming and I apologize if this problem has come up before, but I couldn´t find a solution for it and therefore I ask for your help.

I would like to request your help with an issue I come across when running a piece of code written in IDLE in the terminal. I was unable to find this situation in the FAQ or through an online searce.

Let´s say the name of the saved file is “helloworld” (correctly helloworld.py). When I rightclick on that name and choose “open in terminal”, the terminal opens and gives me the prompt

PS C:\Users\chpap\Documents\Dokumente\Python lernen> (I saved the file in a folder called “Python lernen”).

According to the Python tutorials, the correct way to open helloworld is to input “py helloworld.py”.

However, I am getting the following prompt:

SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
PS C:\Users\chpap\Documents\Dokumente\Python lernen> py helloworld.py
File “C:\Users\chpap\Documents\Dokumente\Python lernen\helloworld.py”, line 1
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32

The 05 of the date Jun 7 2023, 05:45:37 is marked as the culprit. How do I change the date in a manner that allows me to run the code?

Thank you very much for your help
Kind regards

Hi, and welcome to the Forum.

It’s somewhat difficult to say what the issue is, without seeing your code, but what I can tell you is that there should not be any code lines that begin with a number; zero or otherwise.

Post your code up and we’ll have a look at it for you.

It looks like you copied the content of the REPL into helloworld.py, including the output you got from the Python. When I do:

Python 3.11.2 (main, Mar 05 2023, 19:08:04) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> Python 3.11.2 (main, Mar 05 2023, 19:08:04) [GCC] on linux
  File "<stdin>", line 1
    Python 3.11.2 (main, Mar 05 2023, 19:08:04) [GCC] on linux
                             ^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

I now get the same error you get. When you copy program lines from the REPL only copy what you typed. Other text is to be read by you, not by Python.

If I am wrong, refer to what @rob42 wrote.