📜  在 python 代码示例中使用循环拒绝无效输入

📅  最后修改于: 2022-03-11 14:46:59.890000             🧑  作者: Mango

代码示例1
take input
while incorrect input:
    take input
    
#Eg. Taking the month input for the first quarter of the year.
months = ['january', 'february', 'march']
month = input('Select the month').lower()
while month not in months:
  month = input('Oops! Incorrect input. Select month again').lower()