0

How do I remove the NONE output when I run my code?

print("choose from the following options: ")

print("0 quit.")
print("1 Test is_year_same.")
print("2 Test is_leap_year.")
print("3 Test is month_name.")
print("")

choice = int(input("Enter your choice: "))


def check():
  a = int(input("Enter the first year: "))
  b = int(input("Enter the first year again: "))

  if a == b:
    print("Good")
  else:
    print("Bad")


def is_leap_year():
  year = int(input("Enter a year: "))
  
  if (year % 4) == 0:
    if (year % 100) == 0:
        if (year % 400) == 0:
            print("{0} is a leap year".format(year))
        else:
            print("{0} is not a leap year".format(year))
    else:
        print("{0} is a leap year".format(year))
  else:
    print("{0} is not a leap year".format(year))


def options():
  if choice == 0:
   print("0")
  if choice == 1:
    print("1")
    print(check())
  if choice == 2:
    print("2")
    print(is_leap_year())

options()

Sample Output: choose from the folowing options: 0 quit. 1 Test is_year_same. 2 Test is_leap_year. 3 Test is month_name.

Enter your choice: 1
1
Enter the first year: 2001
Enter the first year again: 2001
Good
None
Edric
  • 24,639
  • 13
  • 81
  • 91

1 Answers1

0
if choice == 1:
    print("1")
    print(check())

You are printing the value returned from check function. That is giving the None value. If you want to get rid of the None, remove the print and simply call the function as check()

paradocslover
  • 2,932
  • 3
  • 18
  • 44