i = 2
while True:
if i%3 == 0:
break
print(i)
i += 2
my question is I am failing some answers because I can’t get the program to run right because I doing something wrong that keeps causing my answers to come out in errors can you help?
i = 2
while True:
if i%3 == 0:
break
print(i)
i += 2
my question is I am failing some answers because I can’t get the program to run right because I doing something wrong that keeps causing my answers to come out in errors can you help?
Hi @rxz4040
If your goal is to print the numbers 2 and 4. It is almost correct. You only need to do the propper identation to your code like this:
i=2
while True:
if i%3 == 0:
break
print(i)
i += 2
Python needs the spaces because this language doesn’t use {} to identify where functions, loops, etc starts and ends. So you need to use the same amount of spaces. That’s why the break have more spaces, is because is part of the if conditional, and if conditional is part of the while loop.
Hope it helps to solve to problem, I test your code and works with the identation.
Have a nice day.