Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i run python code?
#1
Hi, i received the attached code and downloaded python. I've pasted it into the python window that looks like a cmd window. Is that what I should do? It gives a bunch of IndentationError: unexpected indent errors though.

Thanks

Attached Files

.py   test.py (Size: 2.04 KB / Downloads: 40)
Reply
#2
There are many ways. One of them is to open the Python file in a Python IDE, then choose run in a menu or use a shortcut. You could install thonny for example and open the file in thonny.
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
(Mar-05-2025, 04:50 PM)Gribouillis Wrote: There are many ways. One of them is to open the Python file in a Python IDE, then choose run in a menu or use a shortcut. You could install thonny for example and open the file in thonny.

Thanks. What is the difference between thonny and pycharm?
Reply
#4
(Mar-05-2025, 05:08 PM)smattiko83 Wrote: What is the difference between thonny and pycharm?
Thonny is an IDE for beginners. There are many many IDEs for Python. You can also program Python by using only a simple editor as I usually do. Then you can run your programs from the command line by typing something like python myscript.py
« We can solve any problem by introducing an extra level of indirection »
Reply
#5
(Mar-05-2025, 04:08 PM)smattiko83 Wrote: Hi, i received the attached code and downloaded python. I've pasted it into the python window that looks like a cmd window. Is that what I should do? It gives a bunch of IndentationError: unexpected indent errors though.

Thanks
Reply
#6
(Mar-05-2025, 04:08 PM)smattiko83 Wrote: Hi, i received the attached code and downloaded python. I've pasted it into the python window that looks like a cmd window. Is that what I should do? It gives a bunch of IndentationError: unexpected indent errors though.

Thanks

Indent errors are just as described... Unlike many other languages, Python is highly dependent upon proper indentation. There's a good chance that adding a stray space (" ") - or the accidental deletion of a single space - somewhere has thrown things off kilter.

Are you getting info about which specific line (or lines) are invoking the indentation errors? If so, that's where the culprit(s) will be lurking.
Reply


Forum Jump:

User Panel Messages

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