Nurbol Y.

asked • 11/24/20

How to Assume the days of the week are numbered 0,1,2,3,4,5,6 from Sunday to Saturday. Write a function which is given the day number, and it returns the day name (a string).

Plzzz help by tomorrow.

Hai D.

``` weekDay = { 0: "Sunday", 1: "Monday", 2: "Tuesday", 3: "Wednesday", 4: "Thursday", 5: "Friday", 6: "saturday" } def is_valid(input_string): try: val = int(input_string) if val < 0 or val > 6: return False return True except ValueError: return False day = input("Enter day number (0-6): ") isValid = is_valid(day) while not isValid: day = input("Invalid input. Enter day number (0-6): ") isValid = is_valid(day) n = int(day) print(weekDay[n]) ```


2 Answers By Expert Tutors


Kevin B. answered • 11/24/20

New to Wyzant

30+ years experience programming in diverse languages and OS

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.