mardi 25 août 2020

How to remove 'None' output value from python function [duplicate]

can anyone help me to remove 'None' output value from a python function?

My function:

def solve(n):
    n = int(input().strip())
    if (n%2 != 0 & n <101):
        print("Good")
    else:
        if (n in range(2,6)):
            print("Bad")
        elif (n in range(6,21)):
            print("Good")
        elif (n > 20 and n < 101):
            print("Bad")

if __name__ == '__main__':
    print(solve(n))

I want the output to be as below:

5
Good

But I am getting as below:

5
Good
None

Please help me in this to remove the 'None' value from the output.

Aucun commentaire:

Enregistrer un commentaire