Kodewick
Start learning →
Basic←→0 / 100

Scale a recipe

#051BasicListsNumbers4 min

The amounts in a recipe (in grams) are for 2 people. Write scale_recipe(amounts, people) to return the amounts for people: each one times people, divided by 2, rounded to one decimal place with round.

Examples
scale_recipe([200, 50, 3], 4)→[400.0, 100.0, 6.0]
scale_recipe([100, 15], 3)→[150.0, 22.5]
main.py
def scale_recipe(amounts, people):
    new_amounts = []
    for grams in amounts:
        # your code here: work out the new amount, add it
        pass
    return new_amounts
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.