lundi 31 octobre 2016

Why isn't my python shell indenting automatically?

I've been given a question:

Write a piece of Python code that prints out one of the following messages:

"string involved" if either varA or varB are strings

"bigger" if varA is larger than varB

"equal" if varA is equal to varB

"smaller" if varA is smaller than varB


Here's my solution:

if type(VarA) == str or type(VarB)==str:
    print("string involved")
elif varA>varB:
    print("bigger")
elif varA==varB:
    print("equal")
else:
    print("smaller")

This looks exactly the same as the given answer, but it is incorrect, and I think it has something to do with my indentation. For some reason, after the if statement on the first line, the shell doesn't automatically indent the next line automatically. Why is this? I had to press TAB after each line. Also, what exactly is wrong with the code that I've written?

Aucun commentaire:

Enregistrer un commentaire