I got list comprehension in general. I’m just not sure if I understood the expression used in the last list comprehension on the exercise.
cuts_under_30 = [hairstyles[i] for i in range(len(hairstyles)) if new_prices[i] < 30] print(cuts_under_30)
I printed some lines to understand what was happening on the list code:
range_hairstyles = range(len(hairstyles)) print(range_hairstyles) print(list(range_hairstyles)) print(hairstyles)
So, my question is:
The list use the expression
hairstyle[i] . This means the loop will iterate on all hairstyle indices? Same for
new_prices[i], or any list I want the loop iterate on all indices?
Also, is this used only for loops? Because i can
print(hairstyles) but not
Thanks, I hope you can understand. English its not my first lenguage.