Question About Exiting Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Question About Exiting Python

When I exit Python I would type "exit()" right? Well, why do you have to put the "()" at the end? Is it important?

29th Nov 2016, 11:07 PM
Angel Gil
3 Answers
+ 7
The parentheses indicate that exit() is a method. You'll learn what those are as you keep going through the Python tutorials. The best way to explain methods right now is that they run code that performs a certain task. exit() is a built-in method to close the console.
29th Nov 2016, 11:45 PM
Tamra
Tamra - avatar
+ 1
Mind that exit() is a method which exits the console. In programs, its better to use sys.exit
30th Nov 2016, 12:09 AM
Dinanath Basumatary
Dinanath Basumatary - avatar
0
Additionally in Python, there is ideally only one way to do something which is debated by some programmers. So exit() method is how you exit python console but then there is quit() which does the same...😅. Just assume that is how it is done if you like the fact.
30th Nov 2016, 10:30 AM
Massamba Sow
Massamba Sow - avatar