How to write a program to print name of day corresponding to the day number given by user

Question:

I want an input like If I type 1 then it will give output Sunday , if I type 2 it will give Monday. I tried this code but it is not working , plz help

days =["Sunday" ,"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

user_input = int(input("Enter Day"))
if user_input == (1,2,3,4,5,6,7) :
    print (days[0,1,2,3,4,5,6])

I want to make my program simple , I am a beginner

Asked By: Hiresh Verma

||

Answers:

days =["Sunday" ,"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

user_input = int(input("Enter Day"))

print (days[user_input - 1])

This will help

Answered By: Divyessh
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")

With a dictionary

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): ")])
Answered By: Seyi Daniel
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))
Answered By: Prixya
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.