What's the use of if __name__ == '__main__': in Python?

Kelvin Wangonya - Aug 3 '19 - - Dev Community

So I'm doing this series and I want to make it as beginner-friendly to Python newbies as possible. I just wrote a piece of code and I want to explain what each line does, but I just can't figure out how to explain if __name__ == '__main__': simply. I mean, I use it all the time but I'm having a hard time explaining it in a way that someone who's just getting into Python would understand. The explanations I'm getting online aren't helping so... someone please #explainlikeimfive 馃槃

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .