May-21-2024, 03:22 PM
For the life of you? We don't want any deaths here!
The problem is the 2 ifs, 1 after the other I think.
I get:
The problem is the 2 ifs, 1 after the other I think.
I get:
x = 5 if x < 10: print("smaller") x += 10 if x > 10: print('bigger')
Output:SyntaxError: invalid syntax
x= 5 if x < 10: print("smaller") x += 10 elif x > 10: print('bigger')
Output:smaller
You need some elifs! (No, not elifants)x = 1 # True is always True, the while loop will keep going unless you stop it! while True: if x < 10: print(f'This is if: {x} is smaller than 10') x += 1 # increase x by 1 elif x == 10: print(f'This is first elif: {x} is less than 20') x += 2 # increase x by 2 elif x > 10 and x <= 20: print(f'This is second elif: {x} is less than 20') x += 3 # increase x by 3 else: print(f'This is else: {x} is {x}') break # stops the while loop