+ 1

The main function in Python

It seems like the main function in the CODE PLAYGROUND does not work. When I use the def main: syntax, my code does not compile...

1st Sep 2018, 8:24 PM
Alhaji
Alhaji - avatar
2 Respuestas
+ 2
i recently started learning python after c++, and i feel like there is no main function... or am i wrong?
1st Sep 2018, 8:28 PM
Data
Data - avatar
+ 3
There is no main() function in python. You can do if __name__ == '__main__': # code This works in Sololearn too. However it's not the same as e.g. int main() in C++. You can define a function main(), but you'll have to call it yourself because it won't be called automatically
1st Sep 2018, 8:58 PM
Anna
Anna - avatar