Functions

Why exactly would we want to use return in python for example in this code:

weather_data = [‘Sunny’, ‘Sunny’, ‘Cloudy’, ‘Raining’, ‘Snowing’]

def threeday_weather_report(weather):
first_day = " Tomorrow the weather will be " + weather[0]
second_day = " The following day it will be " + weather[1]
third_day = " Two days from now it will be " + weather[2]
return first_day, second_day, third_day

I don’t really see what return first_day, second_day, third_day will do and why I would want to use return here.

Well, how else are you going to get any output - in any form - from that function? :slight_smile:

3 Likes