Why This Programs show Error. if __name__ == '__main__': | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why This Programs show Error. if __name__ == '__main__':

def name(name): print(f"This Is {name}") if __name__ == '__main__': name("ahmed") When i import this program to another program this program show error.

9th Apr 2020, 6:20 PM
Syed Ahmed Raza Shah
Syed Ahmed Raza Shah - avatar
1 Answer
+ 4
Syed Ahmed Raza Shah It should work. I ran your exact code from my end here. It works pretty well. I also imported it as a module, it gave me the expected result However, this is what I will advise 1. Make sure you saved this particular code in the same directory of the python script you're trying to import it into 2. Make sure you saved each scripts before you try to executes them Give me a feedback, let's see how it goes together
11th Apr 2020, 5:08 PM
Mujeeb Adeyanju Sunmola
Mujeeb Adeyanju Sunmola - avatar