-5

This is what I have so far:

def delivery(weight):
    if weight > 20:
        return delivery = 20
    if weight >= 20 and weight <= 50:
        return delivery = 20 + (weight)
    if weight > 50:
        return delivery = 10 + (1.2*weight)

delivery(30)

print(delivery)

I continue to get an incorrect outcome that says:

<function delivery at 0x7fb696c2fb90>

When I want my outcome to print 30. How can I fix this?

2 Answers2

1

I think you got confused between = and ==, the first is an assignment (put right value into left), where the second is comparison, returning true or false depends if the two objects are equal or not.

The output you got is an output where you try to print a function.

-1
def delivery(weight):
  if (weight > 20):
    delivery = 20
  elif weight <= 20 and weight >= 50:
    delivery = 20 + (weight)
  elif weight > 50:
    delivery = 10 + (1.2*weight)
  return delivery


weight = 30

print(delivery(weight))

Use this code for what you expect....

JenilDave
  • 606
  • 6
  • 14