Python Forum
write a program which prints the day in english
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
write a program which prints the day in english
#1
Hi, I made post before ( dont mind it, it was when i just started ).
I have a question:
how to print the day in english if i have a date ( input date ).
I managed to do this, but it was long and i cant think that there is a solution way easier and shorter than this..
i need to write in english the day.
import calendar
 
year = int(input("Please choose your year: "))
month = int(input("Please choose your month: "))
day = int(input("Please choose your day: "))
 
print(f"Please enter a date: {day}/{month}/{year}")
calendar = calendar.weekday(year, month, day)
print(f"The day of the week is: {calendar}")
 
if calendar == 0:
    print("Day of the week in english is Monday")
    
elif calendar == 1:
    print("Day of the week in english is Tuesday")
    
elif calendar == 2:
    print("Day of the week in english is Wednesday")
    
elif calendar == 3:
    print("Day of the week in english is Thursday")
    
elif calendar == 4:
    print("Day of the week in english is Friday")
    
elif calendar == 5:
    print("Day of the week in english is Saturday")
    
elif calendar == 6:
    print("Day of the week in english is Sunday")
the link shows the code

how to make it shorter + how to import the date in number to date in english?
i answered for it correctly ( as you can check there ), but its long and slappy...[Image: bJf9]
Yoriz write Jul-24-2021, 06:34 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
write a program which prints the day in english - by ben1122 - Jul-24-2021, 05:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  zfill prints extra et the end of a var tester_V 4 927 Mar-24-2023, 06:59 PM
Last Post: tester_V
  (python) Can i get some help fixing a English to Morse translator? Pls AlexPython 7 1,649 Sep-12-2022, 02:55 AM
Last Post: AlexPython
  variable prints without being declared. ClockPillow 2 1,834 Jul-11-2021, 12:13 AM
Last Post: ClockPillow
  More non english characters johnboy1974 8 4,560 Apr-23-2021, 02:35 PM
Last Post: snippsat
  Output prints Account.id at the end? LastStopDEVS 5 2,844 Dec-19-2020, 05:59 AM
Last Post: buran
  I have an index error inline 76 but I write the program in a way that cant reach tha abbaszandi 2 2,091 Nov-13-2020, 07:43 AM
Last Post: buran
  Try/Exept prints only ones tester_V 11 3,950 Nov-03-2020, 02:38 AM
Last Post: tester_V
  loop only prints last character. mcmxl22 1 1,747 Feb-17-2020, 02:36 AM
Last Post: menator01
  How to write a script to execute a program need passing additional input? larkypython 2 2,585 Nov-23-2019, 04:38 AM
Last Post: larkypython
  English interpretation of the following file handing snippet mortch 5 3,214 May-30-2019, 08:10 AM
Last Post: mortch

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020