3 回答

TA貢獻1878條經(jīng)驗 獲得超4個贊
days =["Sunday" ,"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
user_input = int(input("Enter Day (from 1-7)"))
if user_input:
print (days[user_input-1])
else:
print ("Your input is not valid")
帶著字典
days_dict ={'1':"Sunday" ,'2':"Monday",'3':"Tuesday", '4':"Wednesday", '5':"Thursday", '6':"Friday", '7':"Saturday"}
print (days_dict[input("Enter Day (from 1-7): ")])

TA貢獻1845條經(jīng)驗 獲得超8個贊
days =["Sunday" ,"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
user_input = int(input("Enter Day"))
print (days[user_input - 1])
這會有所幫助

TA貢獻2011條經(jīng)驗 獲得超2個贊
day_number = int(input("Enter day number: "))
days = {
1:'SUNDAY',
2:'MONDAY',
3:'TUESDAY',
4:'WEDNESDAY',
5:'THURSDAY',
6:'FRIDAY',
7:'SATURDAY'
}
print(days.get(day_number))
添加回答
舉報