Getting There [ 3/7]


#1

I honestly cannot figure out what’s really wrong with this code. I’d appreciate an explanation. Please, and thanks.


#2

I just retyped the whole things just with no spaces before and after ==, and it worked. What the heck?


#3

Indentation is a very funny thing (I’m actually lying to you, it can be very annoying) in that if the program detects even a single differentiation in the use of spaces or tabs that you have used to indent, it will throw an indentation error.

You also have to worry about the fact that you actually can indent incorrectly. Let me give you some visuals:

# indention using space & tab example
def test_function():
  print('I just indented with two spaces!')
  print('I just indented with a tab!')
  print('I won\'t even make it this far, because the program is going to fail due to an indention error!')

# indention used incorrectly example
def test_function_two():
  print ('This is indented correctly, and is just fine!')
  if 1 == (2-2):
    print ('This is also indented correctly!')
  elif 1 == 1:
  print ('This is not indented correctly and will throw an error!')

Just mind your indentation, and how you use them, and you’ll be fine :wink:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.