Sal's shipping "TypeError" "nonetype"

Traceback (most recent call last):
File “”, line 43, in
File “”, line 35, in best_price
if ground < drone and ground < premium:
TypeError: ‘<’ not supported between instances of ‘NoneType’ and ‘NoneType’

This is error I keep receiving any thoughts?

Hello @matty2fatty, welcome to the forums! The print() function effectively returns None. Which means, in the drone_ship and ground_ship functions, like here:

  return print(price * weight)

You’re effectively returning None. You can’t use comparison operators like < or > with None:

None > None
#throws an error
3 > None
#throws an error
None > 3
#throws an error

Thanks so much @codeneutrino, lol I actually was about to post that I was pretty sure that was the solution cause I got it to work finally. but I have new question … to make the last function work why do I need to put the str() for the values in the final function like so…

thanks again and you’re awesome!!!

It’s because you have line like the following "This is a string" + name. The + is used to combine two items (in this case you want to add to the end of your string, right?) but what is the code supposed to do when the second item is not a string (like in your example). You’ll get type errors since you’re trying to combine two different data types. If you use str() beforehand you convert the other variable to a string and therefore the concatenation is straightforward.

A neat alternative to this, if you’re calling str() all the time just to print is to use string formatting instead-