Python Forum
Programme will not returns the day number not the day name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programme will not returns the day number not the day name
#4
Hello Gribouillis

Thank you for your prompt reply and I have made the changes you suggest but still do not get the output as the day name. Please see below

n = input("Enter a number 0 to 6: ")
day_of_the_week = n

def day_of_the_week (n):
    if n == 0:
        return "Sunday"
    elif n == 1:
        return "Monday"
    elif n == 2:
        return "Tuesday"
    elif n == 3:
        return "Wednesday"
    elif n == 4:
        return "Thursday"
    elif n == 5:
        return "Friday"
    elif n == 6:
        return "Saturday"
    else:
        return "Invalid number"

print("The day of the week is ", day_of_the_week(n))
= RESTART: C:/Users/John/Documents/John''s files/Work/Coding/Think Like a Computer Scientist/Programmes/day_of_the_week.py
Enter a number 0 to 6: 2
The day of the week is Invalid number
>>>
And the output is:

Output:

Hello Gribouillis and Buran

Thanks for all your help problem solved and I understand why.
Reply


Messages In This Thread
RE: Programme will not returns the day number not the day name - by Oldman45 - Jul-27-2020, 10:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How returns behave in a function with multiple returns? khasbay 1 314 May-19-2024, 08:48 AM
Last Post: deanhystad
  Why am I getting this error from Dave Beazly's programme? Pedroski55 4 544 Apr-26-2024, 12:31 PM
Last Post: Pedroski55
  Call a bash script from within a Python programme Pedroski55 6 2,661 Dec-06-2021, 01:53 PM
Last Post: DeaD_EyE
  Can you tell me if this python programme will get me in trouble with my organisation? abstraction 8 3,950 Feb-25-2019, 12:13 PM
Last Post: metulburr
  [Regex] Findall returns wrong number of hits Winfried 8 6,083 Aug-23-2018, 02:21 PM
Last Post: Winfried

Forum Jump:

User Panel Messages

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