I'm trying to learn python. I found a question saying correct this:
def main():
assert ___ == type("Hello World").__name__
assert ___ == isinstance("Hello World", str)
if __name__=="__main__":
main()
I tried:
__some__={}
def main():
assert __some__ == type("Hello World").__name__
assert __some__ == isinstance("Hello World", str)
if __name__=="__main__":
main()
When I run this, I'm getting AssertionError:
Traceback (most recent call last):
Line 6, in <module>
main()
Line 3, in main
assert __some__ == type("Hello World").__name__
AssertionError
I found that assert is used to specify a condition and an exception will be raised when that condition fails. I even used python tutor, but if I put assert somevariable I'm getting assertion error. I'm unable to understand to understand how to use == and assert to accomplish some task.
___? Have you tried running the expressions to see what values they give?print(isinstance("Hello World", str))to see what you get? Or read the docs forisinstance? Or read up on assertions in Python?