samedi 24 octobre 2020

Why do I keep getting the output I want and an unwanted "none"

def car(wheels,bodies,figures):
  car_by_wheels=wheels//4
  car_by_figures=figures/2
  if figures//2 >= car_by_wheels and bodies >= car_by_wheels:
    print(car_by_wheels)
  elif car_by_wheels >= car_by_figures and bodies >= car_by_figures:
    print(car_by_figures)
  elif car_by_wheels >= bodies and car_by_figures >= bodies:
    print(bodies)
  else:
    print("0")

print(car(3,29,54))

I tried a few other examples and the code works fine but I keep getting none. The code checks how many cars can be made from the inputted argument if the minimum requirements are as follows: 4 wheels, 2 figures and one body

Aucun commentaire:

Enregistrer un commentaire