`if __name__ == '__main()__': does not work as Expected

In this Lab: “Build a Player Interface”,

Why when I write:

if __name__ == '__main()__':
    pawn = Pawn()
    print(type(Player))
    print("\n\n", type(pawn),'\n\n')
    print(pawn.make_move())
else:
	print('Not in main()')

the output in console and terminal shows 'Not in main()'. Why? The other labs were not like this or I got something wrong?

Hi @reThinker

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Happy coding

It’ll make a double topic now. Suggestions?

Create a new topic, a moderator can merge them.

Make sure you post all your code.

Have you looked at what the __name__ is at that time? Add print(__name__) at the bottom, to check it.

I’ll give it a try. Then I will reply.

I understood it was my wrong code that caused this
I wrote(As mentiond in the subject of the Topic):slight_smile:

if __name__ == ‘__main()__

While I had to write:

if __name__ == '__main__':'

@sanity , in this forum, I have seen that it is recommended not to share a working code because it defies the nature of learning. Please guide me how can I share my passed code while respecting this recommendation?

@Teller Not a good idea because it does not give me the toolbar I have here. It does not have a preview.