Understanding this zip() example

Hey all,

Struggling to understand this for loop. Specifically, I’m not sure what:

zip(range(0, 135, 27), days):
    each_day_traffic = traffic[i:i+27]

is really doing?

Screen Link:

My Code:

days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
traffic_per_day = {}
for i, day in zip(range(0, 135, 27), days):
    each_day_traffic = traffic[i:i+27]
    traffic_per_day[day] = each_day_traffic

I feel comfortable answering the question for this lesson, as it doesn’t really require me to understand anything other than that traffic_per_day is a dictionary. However, should I understand at this point what the above is doing?

I think I understand how zip works, but unsure about the range values, and
[i:i+27] ?

Thanks :slight_smile:

1 Like

Hi!
I found a very good explanation for this problem!
Here is the Why does the range look like this? - #2 by dash.debasmita

1 Like