Python novice: print(some_function()) Why is None stamped at the end.

Asked 2 weeks ago, Updated 2 weeks ago, 2 views

def num_of_day(year, month) :
    if (str(month).isnumeric() == 0) | (month < 1) | (month > 12) | (str(year).isnumeric() == 0) | (year < 0) :
        print('Something is wrong')
    elif (str(month).isnumeric() == 1) & (str(year).isnumeric() == 1) & (year >= 0) :
            thirty = (1, 3, 5, 7, 8, 10, 12, 4, 6, 9, 11)
            for twelve in thirty :
                if month == twelve :
                    for one in thirty[0 : 7] :
                        if month == one :
                            print(31)
                    for zero in thirty[-4 :] :
                        if month == zero :
                            print(30)
    else :
        print('Something is wrong.')

I wrote the same code as above

print(num_of_day(2021, 6))

When you run

30
None

This is the result. Can you tell me what "None" is? What do I do to make it not come out?

python

2022-09-20 15:59

1 Answers

num_of_day(2021, 6)

Just run

30

It's over.

None is the return value of the num_of_day function.


2022-09-20 15:59

If you have any answers or tips


© 2022 pinfo. All rights reserved.