dimanche 12 juillet 2020

Solving a problem in python - first conditional statement is skipped even though it's true [closed]

Sorry in advance to all offended by the noob question. (I crawled SOF for similar issues, but those seem too techy and I am not able to apply it to my particular situation). Trying to solve a problem in Hyperskill Python track. The task is to calculate if there are enough supplies for requested # of cups of coffee in the machine. And report the results.

Here's my code:

water_left=int(input())
milk_left=int(input())
beans_left=int(input())
coffee_needed = int(input())
cups_water = water_left//200
cups_milk = milk_left//50
cups_beans = beans_left//15
enough_coffee = [cups_water, cups_milk, cups_beans]
lowest = int(min(enough_coffee))
more = lowest - 1
if coffee_needed < lowest:
    print("No, I can make only " + str(lowest) + " cups of coffee")
elif all(i > 1 for i in enough_coffee):
    print("Yes, I can make that amount of coffee (and even " + str(more) + " more than that)")
elif all(i > 0 for i in enough_coffee):
    print("Yes, I can make that amount of coffee")

when testing the case with the input of 599, 250, 200, 10 somehow I get "Yes, I can make that amount of coffee..." Instead of "No..." Even though the first condition is clearly met.

I 've spent quite some time with this problem and could use some help - what am I missing?

Aucun commentaire:

Enregistrer un commentaire