0

Please some one explain this what iterator is j

smart_multiples = {i: [j for j in range(20) if not j % i] for i in range(2, 10)} print(smart_multiples

14th Jan 2020, 7:29 PM
Sultan
2 Réponses
+ 2
That's a comprehension creating an iterable. You might wanna read this: https://code.sololearn.com/ck6HicJ6Z8jG/?ref=app
14th Jan 2020, 7:52 PM
HonFu
HonFu - avatar
0
Nidified comprehension, to be exact. The outer one {} is a dictionary comprehension, which generates 8 couples key -> list of multiples of the key. The 8 list of multiples are generated by 8 list comprehensions []
14th Jan 2020, 8:45 PM
Bilbo Baggins
Bilbo Baggins - avatar