【发布时间】:2019-12-14 13:19:50
【问题描述】:
def get_user_choice():
global user_choice
''' 3users give their numbers to be validated'''
for i in range(1, 4):
choices = []
** choices = input("User {}, please enter 5 numbers separated by ',' :".format(i))
nums = choices.split(',')
while True:
if len(nums) != 5:
print(" Wrong choice,You have to enter 5 numbers separated by ','")
break
for nr in nums:
if nr.isdigit():
if int(nr) < 1 or int(nr) > 25:
print(" Wrong! Enter 5 Numbers between 1 and 25")
continue
else:
print(nr + " is not a number, try again")
continue
# How can i go back to ** from here????
【问题讨论】:
-
与其使用
continue,不如使用break。它应该跳出内循环,回到外循环。 -
点评来源: 请在您的帖子中添加描述和问题。见:HOW TO ASK