I tried to search for tutorials on youtube but I don't know what to search for this kind of problem I also tried to check my Code runner extension
Asked
Active
Viewed 53 times
-3
-
1Please, do not show text with images. They are not searchable, not copy-paste-able and much heavier than needed. Moreover they affect accessibility negatively. Please copy-paste the text in your question and [format it properly](https://stackoverflow.com/help/formatting), instead. – Constantin Hong Jul 13 '23 at 09:01
-
2you should call main() in your script – alegria Jul 13 '23 at 09:01
-
It looks like you have two functions, but call neither. Did you mean to add `main()` as the last line? – quamrana Jul 13 '23 at 09:02
-
dear vynn01 try reading a tutorial first https://www.w3schools.com/python/ – Kostas Nitaf Jul 13 '23 at 09:18
-
Does this answer your question? [How to run a python function](https://stackoverflow.com/questions/15103626/how-to-run-a-python-function) – Peter Jul 13 '23 at 09:49
3 Answers
1
Python doesn't automatically runs main()
when started, you need to call it yourself. Therefore, your program is currently only made of functions, and there's nothing to run, it actually runs properly.
You may want to add this code for the behaviour you're expecting:
if __name__ == "__main__":
main()
This will call the main
function when the program is started from the command line.

Gugu72
- 2,052
- 13
- 35
0
You defined the main function, but you never call it.
add main() to the end of your code.
0
Python won’t call any function automatically when the program is run. You have to call the function for it to run. To run the main() function, call it like below:
main()
Alternatively, if you want to run any function from the command line when the program is run, you have to use the following code:
if __name__ == "__main__":
main() #Call your function

Dinux
- 644
- 1
- 6
- 19