请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。
程序员文章站
2022-07-09 21:20:47
```
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)
上一篇: 开发时候常用的js方法封装
下一篇: async语法升级踩坑小记