【发布时间】:2020-10-13 18:28:07
【问题描述】:
我需要帮助创建一个函数来确保用户的输入是有效的。如果它无效,那么我们需要要求他们重新输入不同的信息。
第一个函数需要有参数prompt,low,high,prompt要求用户输入,low是下界,high是上界。
这是我目前所拥有的:
def get_int(prompt,low,high):
inputs= int(input(prompt))
while inputs<= low and inputs >=high:
inputs= int(input(prompt))
return inputs
【问题讨论】:
标签: python validation input