Python3的WHILE,IF例句

以缩进符和冒号标志语块:

 

#!/usr/bin/python
#Filename: if.py

number = 23
running = True

while running:
    guess = int(input('Enter an integer : '))

    if guess == number:
        print('Congratulations,you guessed it.')
        print('(but you do not win any prizes!)')
        running = False
    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.')

Python3的WHILE,IF例句