나는 이렇게 학습한다/Algorithm & SQL

1101. Fix your code before the garden dies!

daco2020 2022. 11. 1. 19:58
반응형

You have an award-winning garden and every day the plants need exactly 40mm of water. You created a great piece of JavaScript to calculate the amount of water your plants will need when you have taken into consideration the amount of rain water that is forecast for the day. Your jealous neighbour hacked your computer and filled your code with bugs.

Your task is to debug the code before your plants die!



Solution:

def rain_amount(mm: int, need: int = 40) -> str:
    if result := need-mm > 0 and f"You need to give your plant {need-mm}mm of water": ...
    elif result := "Your plant has had more than enough water for today!": ...
    return result


반응형