Here is my correct code from lesson 2:
def is_even(x): for i in x: if i % 2 == 0: print i, "is even" else: print i, "is odd" numbers = [25, 60, 85, 143] is_even(numbers)
Here is my correct code from lesson 3:
def is_int(x): if float(x) - int(x) == 0: print x, "is an integer" return True else: print x, "is not an integer" return False is_int(7.5)
In lesson 2, when I indent my print statement 4 spaces, it works. If I only do two spaces, it gives me an indentation error.
In lesson 3, it’s the opposite. When I indent 2 spaces, my print statement works. If I try to indent 4 spaces, I get an indentation error.
Can anyone explain this? I feel like I am not understanding the indentation rules in python. I don’t understand why these two function are so different.