#!usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Zhuyuzhe
MyAge = 20
# V1
GuessAge = int( input('input your guess age:') )
if GuessAge == MyAge:
print('Congratulations! 猜对了')
elif GuessAge > MyAge:
print('猜大了!')
else:
print('猜小了!')
# V2
print('input your guess age:')
for i in range(10):
if i < 3:
GuessAge = int( input() )
if GuessAge == MyAge:
print('Congratulations! 猜对了')
break # 回答正确,跳出整个循环
elif GuessAge > MyAge:
print('猜大了!')
else:
print('猜小了!')
else:
print('太多次了!')
break
# V3
counter = 0
for i in range(20):
print('------>counter:',counter)
if counter < 3:
GuessAge = int( input('input your guess age:') )
if GuessAge == MyAge:
print('Congratulations! 猜对了')
break # 回答正确,跳出整个循环
elif GuessAge > MyAge:
print('猜大了!')
else:
print('猜小了!')
else:
continue_confirm = input('还想继续吗?(Y/N)')
if continue_confirm == 'y':
counter = 0
continue
else:
print('再见!')
break
counter += 1