number = 64
running = True
while running:
guess = int(input("write the number :"))
if guess == number:
print("Congrads! You won!")
running = False
elif guess < number:
print("No, the number is a bit bigger")
else:
print("No, the number is less")
else:
print("while cycle is over.")
else:
print("end")
i expected a working code, but there's bugs i can't see, it says the problem in line four, but again, i can't see nothing wrong with it
In addition to G. Anderson you have following errors in the code (look comments):
number = 64
running = True
while running:
guess = int(input("write the number :")) # <-- is indented too much
if guess == number:
print("Congrads! You won!") # <-- also indented "two tabs"
running = False # <-- also indented "two tabs"
elif guess < number:
print("No, the number is a bit bigger")
else:
print("No, the number is less")
else:
print("while cycle is over.")
else: # <-- second else?
print("end")
This would be a fix:
number = 64
running = True
while running:
guess = int(input("write the number :"))
if guess == number:
print("Congrads! You won!")
running = False
elif guess < number:
print("No, the number is a bit bigger")
else:
print("No, the number is less")
else:
print("while cycle is over.")