Alright so here is my code, I get the result I want but I keep getting the \"None\" value under it. How do I eliminate the \"None\" value?
n = input(\"What day o
Change all the print
statements in your days(n)
function to return
instead.
days
never returns anything, so it implicitly returns None
. Change all of the print
statements in days
to return
statements:
def days(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 "Thrusday"
elif n == 5:
return "Friday"
elif n == 6:
return "Saturday"
elif n >= 7:
return days(n % 7)
This should do the trick:
days = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"]
print days[(n+r) % 7]
You print in function days and print result from function days. Because of function days returns nothing it prints None.