请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。
程序员文章站
2022-04-15 11:06:02
```
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... ......
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)
上一篇: 第25天面向对象编程详解之继承
下一篇: 机器学习mlxtend_01