Always get printed value of “None”

后端 未结 4 394
小鲜肉
小鲜肉 2021-01-28 14:32

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         


        
4条回答
  •  花落未央
    2021-01-28 14:50

    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)
    

提交回复
热议问题