代码语言:javascript复制
state = 1
def set_state(state):
while state:
set = int(input('请输入9或5,显示"hello world"n'))
if set == 9 or set == 5:
print('hello world')
state = int(input('输入1继续,输入0停止!n'))
else:
print('请输入要求的值!')
set_state(state)
# break
set_state(state)
print('end')
Output:
------------------------------------
请输入9或5,显示"hello world"
9
hello world
输入1继续,输入0停止!
1
请输入9或5,显示"hello world"
9
hello world
输入1继续,输入0停止!
5
请输入9或5,显示"hello world"
9
hello world
输入1继续,输入0停止!
0
end
------------------------------------