Write a python code that takes a dayno as an input and display the corresponding day name as
an output(if elif else). If y ser enters wrong input then display error message
Answers
Answered by
1
days = {1: "Mon", 2: "Tues", 3: "Wednes", 4: "Thurs", 5: "Fri", 6: "Satur", 7: "Sun"}
print(f"{days[n]}day") if (n := int(input("num: "))) in days else print("invalid input")
Answered by
0
Explanation:
# Taken day number from user
weekday = int(input("Enter weekday day number (1-7) : "))
if weekday == 1 :
print("\nMonday");
elif weekday == 2 :
print("\nTuesday")
elif(weekday == 3) :
print("\nWednesday")
elif(weekday == 4) :
print("\nThursday")
elif(weekday == 5) :
print("\nFriday")
elif(weekday == 6) :
print("\nSaturday")
elif (weekday == 7) :
print("\nSunday")
else :
print("\nPlease enter weekday number between 1-7.")
Similar questions