0

I understand what this code does. However, I don't understand how the syntax works. I hope that somebody can explain me these loops in detail. Thanks. I appreciate your help

minY = min([y for yValues in yAll for y in yValues])
xValues = [1,2,3,4] 
yValues0 = [6,7.5,8,7.5] 
yValues1 = [5.5,6.5,50,6] 
yValues2 = [6.5,7,8,7] 
yAll = [yValues0, yValues1, yValues2]  # list of lists 

# flatten list of lists retrieving minimum value 
minY = min([y for yValues in yAll for y in yValues])
Diogenis Siganos
  • 779
  • 7
  • 17
  • See https://stackoverflow.com/questions/18551458/how-to-frame-two-for-loops-in-list-comprehension-python – Ollie Apr 06 '20 at 05:55
  • Those are called 'list comprehensions', and you can check a lot of material on them online, one of which currently being: https://www.programiz.com/python-programming/list-comprehension. Good day to you, – Alceste_ Apr 06 '20 at 05:57

0 Answers0