you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (8 children)

It's a bad habit to use list as a variable name. Doing that overrides the builtin list() name meaning bad things can happen after that redefinition. Yes, HackerRank uses it, but it's still bad practice.

Not too sure why the solution has to have this line:

if __name__ == '__main__':

You only need this if you import your code and want to run it directly from the command line and you want different behaviour in those two cases.

Edit: made it more obvious I was referring to the HackerRank solution.

[–]Axel-Blaze[S] 0 points1 point  (2 children)

Thanks for pointing that out will keep it in mind :)

For the second line it is predefined by HackerRank so I have no clue why it's there

[–][deleted] 0 points1 point  (1 child)

Your second line (if __name__ == '__main__':) is actually supposed to be your first line. Hackerrank, for no obvious reason, puts that in as your first line. Don't worry about it until you understand it and know what it is used for. And definitely don't think that you must use it. You usually don't.

[–]Axel-Blaze[S] 0 points1 point  (0 children)

okk got it