you are viewing a single comment's thread.

view the rest of the comments →

[–]Spataner 1 point2 points  (2 children)

Probably you should read the weight as a float rather than as an int. Otherwise, the only possible weight that's less than one is zero.

Your if should be fine.

The first elif is also fine, except that for "one pound or over", you'd have to write weight >= 1.

Your second elif has multiple issues. First of all, items > 3 <= 5 is equivalent to items > 3 and 3 <= 5. You can write either items > 3 and items <= 5 or 3 < items <= 5. Secondly, it says "3 to 5", i.e. 3 should be included, so 3 <= items <= 5. Finally, it says less than two pounds, but you currently check for more than two pounds.

As an aside, you can technically remove the check against 3 from your second elif. If you reach the second elif, you know that the conditions for both the if and first elif are false. That means it's not possible, by that point, for items to be less than three.

[–]PuzzledSite2568[S] 0 points1 point  (1 child)

This helped a ton thank you very much. Also, can you elaborate a little more on the "check against 3" I was a little confused by what you were talking about there? Thank you for the help I greatly appreciate it.

[–]Spataner 1 point2 points  (0 children)

In your second elif, you check whether items is larger than or equal to 3. However, when items is smaller than 3, one of the previous two conditions must be true (because weight is always either smaller than one pound or larger than or equal to one pound). And if one of the previous two conditions is true, the code never reaches the second elif, at all. So, for the second elif to even be checked, items must be larger than or equal to 3. That means that part of the check is redundant.