编程实现:编写函数实现输入英文星期几的第一个字母,用来判断是星期几,如果第一个字母相同,则继续判断第二个字母,以此类推,要求函数能将判断结果输出。
时间: 2024-01-05 07:02:13 浏览: 116
以下是Python3的代码实现:
```python
def get_weekday(letter):
if letter == 'M':
print("Monday")
elif letter == 'W':
print("Wednesday")
elif letter == 'F':
print("Friday")
elif letter == 'T':
next_letter = input("Enter the second letter: ")
if next_letter == 'u':
print("Tuesday")
elif next_letter == 'h':
print("Thursday")
else:
print("Invalid input")
elif letter == 'S':
next_letter = input("Enter the second letter: ")
if next_letter == 'a':
print("Saturday")
elif next_letter == 'u':
print("Sunday")
else:
print("Invalid input")
else:
print("Invalid input")
letter = input("Enter the first letter: ")
get_weekday(letter.upper())
```
运行结果如下:
```
Enter the first letter: t
Enter the second letter: u
Tuesday
```
阅读全文
相关推荐


















