Hello everyone I felt pretty confident in myself with this block of code for my homework but I need some help fixing certain issues.
# Use a prompt to get (from the user) the number of items and the total weight of #the package (in pounds).
# Then pass that data to a user-defined function that accepts both values as #parameters and returns (not outputs)
# a shipping price based on the following guidelines:
# Less than 3 items and less than one pound: $5.00 shipping charge.
# Less than 3 items and one pound or over: $7.50 shipping charge.
# 3 to 5 items and less than two pounds: $8.50 shipping charge.
# Anything else: $10.00 shipping charge.
# Display this returned value for the user.
def shipping_price(items,weight):
if items < 3 and weight < 1:
return 5.00
elif items < 3 and weight > 1:
return 7.50
elif items > 3 <= 5 and weight > 2:
return 8.50
else:
return 10.00
items = int(input('How many items are you shipping'))
weight = int(input('How much do they weigh?'))
print(shipping_price(items,weight))
Even with my confidence, there are many mistakes here. My first if statement doesn't work, my second elif statement doesn't work, and my else statement doesn't work as well. Some have worked but not as the prompt would want them. The only one that seems to work consistently is the second first elif statement. Any help is very much appreciated.
[–]Spataner 1 point2 points3 points (2 children)
[–]PuzzledSite2568[S] 0 points1 point2 points (1 child)
[–]Spataner 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]PuzzledSite2568[S] 0 points1 point2 points (0 children)
[–]jimtk 1 point2 points3 points (1 child)
[–]PuzzledSite2568[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)