Lang van stof

Python bootcamp #100DaysOfCode #myNotes

IRL ben ik ook altijd zo lang van stof ;)

def check_resources(order, resources):
    coffee_data = get_coffee_ingredients(order)
    if resources['water'] < coffee_data['water']:
        print("Sorry there is not enough water.")
        return False
    elif resources['milk'] < coffee_data['milk']:
        print("Sorry there is not enough milk.")
        return False
    elif resources['coffee'] < coffee_data['coffee']:
        print("Sorry there is not enough coffee.")
        return False
    else:
        return True

Had veel korter gekund:

    def check_resources(order, resources):
        coffee_data = get_coffee_ingredients(order)
        for item in coffee_data:
            if coffee_data[item] > resources[item]:
                print(f"Sorry there is not enough {item}.")
                return False
            else:
                return True

More from Lucia
All posts