size = (raw_input ('\nWhat Size do you want?').lower()
l_size =['large' , 'lerge' , 'l', 'larg' ,'lorge' ,]
m_size =['m' , 'med' , 'medium']
s_size =['s' , 'small' , 'smell', 'smoll']
如果用户输入不正确,我使用它是为了获得正确的输入
while size not in ('l_size', 'm_size','s_size'):
print ("\033[1;31m Invalid input! Trying Again\n"),
size = raw_input("\033[1;32;40m What Size do you want? \n")
如果用户输入错误,我想从一开始就运行程序
if size in l_size:
print '\nYour coffee is Large! '
elif size in m_size:
print '\n Your Coffee is Medium'
elif size in s_size:
print '\nYour Coffee is Small'
else:
print '\nIncorrect Typing! Type Properly'\
需要列表串联:
删除
raw_input()
周围的额外括号。你知道吗当
size
不在这些列表中时,您需要重置size
,而不是创建新变量num
。就像@iBug所说的,您需要串联列表才能循环。你知道吗相关问题 更多 >
编程相关推荐