Sal's Shipping - Curious result

https://www.codecademy.com/courses/learn-python-3/projects/sals-shipping

I’m working on Sal’s Shipping. I get the final results just fine and pass the quiz. However when I run my code I get a new line, then “None” and then new line before printing my next print function.

def cheap_ship(weight):
  if weight > 10:
    cost = 4.75 * weight
  elif weight > 6:
    cost = 4.00 * weight
  elif weight > 2:
    cost = 3.00 * weight
  else:
    cost = 1.50 * weight
  cost += 20
  return cost

prem_ship = 125.00

def drone_ship(weight):
  if weight > 10:
    cost = 14.25 * weight
  elif weight > 6:
    cost = 12.00 * weight
  elif weight > 2:
    cost = 9.00 * weight
  else:
    cost = 4.50 * weight
  return cost

def compare(weight):
  if cheap_ship(weight) < prem_ship and drone_ship(weight):
    print("Use cheap shipping. It will cost you: "+str(cheap_ship(weight)))
  elif prem_ship < cheap_ship(weight) and drone_ship(weight):
    print("Use premium shipping. It will cost you: $125.00")
  else:
    print("Use drone shipping. It will cost you: " + str(drone_ship(weight)))

print(compare(4.8))

print(compare(41.5))

This is what my Terminal looks like:

Use cheap shipping. It will cost you: 34.4
None
Use premium shipping. It will cost you: $125.00
None

Where do the None come from?! Thanks!

1 Like

Hello @systemwhiz65349, and welcome to the Codecademy Forums!

Here, you are displaying the value returned by the compare function, which is None, because no return value is specified within the function definition:

print(compare(4.8))

print(compare(41.5))

All you really need is:

compare(4.8)

compare(41.5)
2 Likes

I overthought it! Thanks for the quick reply!

1 Like