Sort by

recency

|

688 Discussions

|

  • + 0 comments
    import calendar
    import datetime
    
    m,d,y=map(int,input().split())
    ind=datetime.date(y,m,d).weekday()
    print(calendar.day_name[ind].upper())
    
  • + 0 comments
    import calendar
    date = list(map(int, input().split()))
    print(list(calendar.day_name)[calendar.weekday(date[2],date[0], date[1])].upper())
    
  • + 0 comments
    import calendar
    
    M,D,Y = map(int,input().split())
    
    print(calendar.day_name[calendar.weekday(Y,M,D)].upper())
    
  • + 0 comments

    Maybe my solution could inspire someone :

    I have noticed with print() that weekday() return a number corresponding to the day in a week. (Monday = 0, Tuesday = 1, Wednesday = 2 ... Sunday = 6).

    So I have created a dictionnary and use it with the function calendar.weekday() to return the good day name :

    import calendar
    
    date = list(map(int, input().split()))
    
    days = {
        0: "MONDAY",
        1: "TUESDAY",
        2: "WEDNESDAY",
        3: "THURSDAY",
        4: "FRIDAY",
        5: "SATURDAY",
        6: "SUNDAY"
    }
    
    day_in_week = calendar.weekday(date[2], date[0], date[1])
    print(days[day_in_week])
    
  • + 0 comments
    import calendar
    
    month,day,year=map(int,input().split())
    
    weekday_index = calendar.weekday(year,month,day)
    
    weekday_name =calendar.day_name[weekday_index]
    
    print(weekday_name.upper())