Kodewick
Start learning →
Basic←→0 / 80

Tomato growth

#018BasicComprehensionsLists4 min

There's a row of tomato plants on the balcony, measured last week and again this week. Both lists are the same length and in the same order. Write growth(last_week, this_week) to return how many centimetres each plant grew. Two empty lists give an empty list.

Examples
growth([10, 12, 9], [13, 12, 15])→[3, 0, 6]
growth([], [])→[]
main.py
def growth(last_week, this_week):
    # your code here: a list comprehension with zip, this week minus last week for each plant
    return []
Ctrl + Enter runs too
Result

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