What does TypeError: unorderable types: function() < float() mean?


I am working on: https://www.codecademy.com/courses/learn-python-3/projects/sals-shipping

So I wrote this:

  if weight <= 2:
    price_per_pound = 4.50
  elif weight <= 6:
    price_per_pound = 9.00
  elif weight <= 10:
    price_per_pound = 12.00
    price_per_pound = 14.25
  return weight * price_per_pound


def print_cheapest_shipping_method(weight):
  ground = shipping_cost_ground 
  premium = shipping_cost_premium
  drone = shipping_cost_drone

It is basically saying what different shipping options are and how much they cost. The functions are not important for my question.

I needed to find the cheapest option depending on what the customer chooses as (weight). I wrote this:

if ground < premium and ground < drone:
    method = "standard ground"
    cost = ground
  if premium < ground and premium < drone:
    method = "premium ground"
    cost = premium
  if drone < ground and drone < premium:
    method = "drone"
    cost = drone
  print("The cheapest option available is $%.2f with %s shipping."
       % (cost, method)

After I try to print some results and test it out, it tells me

Traceback (most recent call last):
File “script.py”, line 51, in
File “script.py”, line 35, in print_cheapest_shipping_method
if ground < premium and ground < drone:
TypeError: unorderable types: function() < float()

I don’t understand what the error is telling me. The tutorial video did the same thing and it worked for them. What am I doing wrong?


That’s not a meaningful comparison.

Is a helicopter less than water? uhh. TypeError.

Try comparing numbers instead. Those are meaningfully compared that way.

import sys
sys < 5  # don't compare these two, doesn't make sense, they're of completely different kinds