Logo

Programming-Idioms

History of Idiom 7 > diff from v137 to v138

Edit summary for version 138 by rkrikbaev:
[Python] test

Version 137

2022-10-05, 05:06:10

Version 138

2022-10-05, 05:48:52

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Variables
i,x,items
Variables
i,x,items
Extra Keywords
indices traverse traversal
Extra Keywords
indices traverse traversal
Code
list = [x[1] for x in items]
Code

for x in items:
  print(x[2])
Doc URL
https://docs.python.org/3/library/functions.html#enumerate
Doc URL
https://docs.python.org/3/library/functions.html#enumerate
Origin
https://stackoverflow.com/a/522578/871134
Origin
https://stackoverflow.com/a/522578/871134