def juge(num,week_list):
w = input(‘请输入第%s个字母:‘%num)
w = w.lower()
res = []
state = 0
for week in week_list:
if w == week[0 + num - 1: 1 + num - 1]:
state += 1
res.append(week)
if state == 1:
print(‘是%s‘% res[0])
elif state > 1:
print(‘还要输入一次‘)
num += 1
week_list = res
juge(num, week_list)
else:
print(‘非法输入‘)
if __name__ == ‘__main__‘:
# 初始条件
num = 1
week_list = [‘mon‘, ‘tues‘, ‘wed‘, ‘thur‘, ‘fri‘, ‘sat‘, ‘sun‘]
juge(num, week_list)
原文地址:https://www.cnblogs.com/Py00/p/9842742.html
时间: 2024-10-20 02:04:36