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
#1
I have the following programme:
n = input("Enter a number 0 to 6: ")
day_of_the_week = n

def day_of_the_week ():
    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 ", n)
The out put I get is:
Output:
Python 3.8.4 (tags/v3.8.4:dfa645a, Jul 13 2020, 16:46:45) [MSC v.1924 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> = 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: 4 The day of the week is 4 >>>
Could anyone please advise what I am doing wrong?
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  How returns behave in a function with multiple returns? khasbay 1 920 May-19-2024, 08:48 AM
Last Post: deanhystad
  Why am I getting this error from Dave Beazly's programme? Pedroski55 4 3,021 Apr-26-2024, 12:31 PM
Last Post: Pedroski55
  Call a bash script from within a Python programme Pedroski55 6 3,812 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 5,331 Feb-25-2019, 12:13 PM
Last Post: metulburr
  [Regex] Findall returns wrong number of hits Winfried 8 7,704 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