请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。

#!/usr/bin/python
# -*- coding: UTF-8 -*-
letter = raw_input("Please input first letter:")
letter = letter.upper()
if letter == 'S':
   letter = raw_input("Please input second letter:")
   letter = letter.lower() 
   if letter == 'a':
       print('Saturday')
   elif letter == 'u':
       print('Sunday')
   else:
       print('Input letter no data.')
elif letter == 'T':
   letter = raw_input("Please input second letter:")
   letter = letter.lower() 
   if letter == 'u':
       print('Tuesday')
   elif letter == 'h':
       print('Thursday')
   else:
       print('Input letter no data.')  
elif letter == 'M':
   print('Monday')
elif letter == 'W':
   print('Wednessday')
elif letter == 'F':
   print('Friday')
else:
  print('Input letter no data.')

 以上实例输出结果为:

 

Please input first letter:s
Please input second letter:u
Sunday

 

  

 

posted @ 2019-08-27 16:48  菩提花开  阅读(1019)  评论(0编辑  收藏  举报