i had saved my work then i had reloaded it then it would say syntax when i tried to run it but it worked before
It is difficult to tell what is going on without knowing answers to
Are you using IDLE?
How did you save your work?
How did you reload it?
Then what did you do?
It kind of looks to me like you saved the shell output, and then
reopened it and tried to run it as a script.
The shell output includes text that cannot be run by the Python
interpreter. Things like the welcome message
Python 3.9 ... and the
>>> aren’t Python code, and cannot be run.
Honestly I don’t use IDLE very often so I don’t know why it lets you
save the shell output. It seems confusing to me. But what you can do to
fix it is this:
Start by saving a copy of the file, as a backup.
Then carefully edit the file to remove everything that is not Python
code: the welcome message at the start, all of the
forget to also remove the space after the prompt).
And output of commands will also need to be removed.
Save the file and try to run it again.
At the very least you should get a different error message, but with
luck you will be able to run the code now.
Good luck and feel free to come back with any other questions.
I think Steven is correct. Probably you are trying to execute the output of something that includes the Python prompts that are not part of the program. I used an OCR program to convert your image to text then fixed up the errors in that result until I had the following and it works.
import tkinter window=tkinter.Tk() button=tkinter.Button(window, text="Do not press this button.", width=40) button.pack(padx=10, pady=10) clickcount=0 def onClick(event): global clickcount clickcount=clickcount+1 if clickcount==1: button.configure(text="Seriously? Do. Not. Press. It.") elif clickcount==2: button.configure(text="Gah! Next time, no more button.") else: button.pack_forget() button.bind("<ButtonRelease-1>", onClick) window.mainloop()
In the future it will help to provide the source code as text instead of an image.
thanks guys it works perfectly now i just had to remove the info and the >>>