I'm trying to make the variable number
increase if user guessed the right number! And continue increase the increased one if it is guessed by another user. But it's seem my syntax
is wrong. So i really need your help. Bellow is my code:
#!/usr/bin/python
# Filename: while.py
number = 23
running = True
while running:
guess = int(raw_input('Enter an integer : '))
if guess == number:
print 'Congratulations, you guessed it. The number is now increase'
number += 1 # Increase this so the next user won't know it!
running = False # this causes the while loop to stop
elif guess < number:
print 'No, it is a little higher than that.'
else:
print 'No, it is a little lower than that.'
else:
print 'The while loop is over.'
# Do anything else you want to do here
print 'Done'
You can do it without "running" variable, it's not needed
i don't know properly what you want to do , as i am a beginner . but i know one thing that is wrong in your code is that you have typed else after a while loop . your code doesn't make sense actually , either your indentation is wrong or it is a wrong code as else is only typed after you use if.