Help with sal's shipping

so i got to the end of sal’s shipping, and when i run the code, i get “none” at the end. I’m not sure where i went wrong and how to correct it.

def gsc(weight):
  if weight <= 2:
    ppp = 1.50
  elif weight >2 and weight <=6:
    ppp = 3.00
  elif weight > 6 and weight <= 10:
    ppp =  4.00
  elif weight > 10:
    ppp = 4.75
  return ppp * weight + 20

pgsc = 125.00

def dsc(weight):
  if weight <= 2:
    ppp = 4.50
  elif weight >2 and weight <=6:
    ppp = 9.00
  elif weight > 6 and weight <= 10:
    ppp = 12.00
  elif weight > 10:
    ppp = 14.25
  return ppp * weight

def print_cheapest_shipping(weight):
  g = gsc(weight)
  p = pgsc
  d = dsc(weight)
  if g < p and g < d:
    price = g
    method = "Ground"
  elif d < g and d < p:
    price = d
    method = "Drone"
    price = p 
    method = "Premium ground"
  print ("You should ship by " +method +" it will be $" +str(price))

In your
def print_cheapest_shipping(weight)
you never returned anything, so the computer provides ‘None’ as a a placeholder. Instead of doing
print (“You should ship by " +method +” it will be " +str(price)) you should do return("You should ship by " +method +" it will be " +str(price))
give or take a few parentheses depending on Python version.


Thanks for the clarification

Step 6 of the instructions ask the user to do this:

… write a function that takes one parameter, weight and prints a statement that tells the user

  • The shipping method that is cheapest.
  • How much it would cost to ship a package of said weight using this method.

Accordingly, it is fine to have the print_cheapest_shipping function output the result to the console instead of having it return that result. Without a return statement, that function will return None, and that is an acceptable way to design it. If you choose that option, then just simply call the function as follows, instead of passing the result of calling it to the print function:


With that function call, None will not be displayed in the console.