---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
PLR1736 [*] List index lookup in `enumerate()` loop
 --> unnecessary_list_index_lookup.py:7:6
  |
6 | def fix_these():
7 |     [letters[index] for index, letter in enumerate(letters)]  # PLR1736
  |      ^^^^^^^^^^^^^^
8 |     {letters[index] for index, letter in enumerate(letters)}  # PLR1736
9 |     {letter: letters[index] for index, letter in enumerate(letters)}  # PLR1736
  |
help: Use the loop variable directly
  |
6 | def fix_these():
  -     [letters[index] for index, letter in enumerate(letters)]  # PLR1736
7 +     [letter for index, letter in enumerate(letters)]  # PLR1736
8 |     {letters[index] for index, letter in enumerate(letters)}  # PLR1736
  |

PLR1736 [*] List index lookup in `enumerate()` loop
 --> unnecessary_list_index_lookup.py:8:6
  |
6 | def fix_these():
7 |     [letters[index] for index, letter in enumerate(letters)]  # PLR1736
8 |     {letters[index] for index, letter in enumerate(letters)}  # PLR1736
  |      ^^^^^^^^^^^^^^
9 |     {letter: letters[index] for index, letter in enumerate(letters)}  # PLR1736
  |
help: Use the loop variable directly
  |
7 |     [letters[index] for index, letter in enumerate(letters)]  # PLR1736
  -     {letters[index] for index, letter in enumerate(letters)}  # PLR1736
8 +     {letter for index, letter in enumerate(letters)}  # PLR1736
9 |     {letter: letters[index] for index, letter in enumerate(letters)}  # PLR1736
  |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:9:14
   |
 7 |     [letters[index] for index, letter in enumerate(letters)]  # PLR1736
 8 |     {letters[index] for index, letter in enumerate(letters)}  # PLR1736
 9 |     {letter: letters[index] for index, letter in enumerate(letters)}  # PLR1736
   |              ^^^^^^^^^^^^^^
10 |
11 |     for index, letter in enumerate(letters):
   |
help: Use the loop variable directly
   |
8  |     {letters[index] for index, letter in enumerate(letters)}  # PLR1736
   -     {letter: letters[index] for index, letter in enumerate(letters)}  # PLR1736
9  +     {letter: letter for index, letter in enumerate(letters)}  # PLR1736
10 |
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:12:15
   |
11 |     for index, letter in enumerate(letters):
12 |         print(letters[index])  # PLR1736
   |               ^^^^^^^^^^^^^^
13 |         blah = letters[index]  # PLR1736
14 |         assert letters[index]  == "d"  # PLR1736
   |
help: Use the loop variable directly
   |
11 |     for index, letter in enumerate(letters):
   -         print(letters[index])  # PLR1736
12 +         print(letter)  # PLR1736
13 |         blah = letters[index]  # PLR1736
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:13:16
   |
11 |     for index, letter in enumerate(letters):
12 |         print(letters[index])  # PLR1736
13 |         blah = letters[index]  # PLR1736
   |                ^^^^^^^^^^^^^^
14 |         assert letters[index]  == "d"  # PLR1736
   |
help: Use the loop variable directly
   |
12 |         print(letters[index])  # PLR1736
   -         blah = letters[index]  # PLR1736
13 +         blah = letter  # PLR1736
14 |         assert letters[index]  == "d"  # PLR1736
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:14:16
   |
12 |         print(letters[index])  # PLR1736
13 |         blah = letters[index]  # PLR1736
14 |         assert letters[index]  == "d"  # PLR1736
   |                ^^^^^^^^^^^^^^
15 |
16 |     for index, letter in builtins.enumerate(letters):
   |
help: Use the loop variable directly
   |
13 |         blah = letters[index]  # PLR1736
   -         assert letters[index]  == "d"  # PLR1736
14 +         assert letter  == "d"  # PLR1736
15 |
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:17:15
   |
16 |     for index, letter in builtins.enumerate(letters):
17 |         print(letters[index])  # PLR1736
   |               ^^^^^^^^^^^^^^
18 |         blah = letters[index]  # PLR1736
19 |         assert letters[index]  == "d"  # PLR1736
   |
help: Use the loop variable directly
   |
16 |     for index, letter in builtins.enumerate(letters):
   -         print(letters[index])  # PLR1736
17 +         print(letter)  # PLR1736
18 |         blah = letters[index]  # PLR1736
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:18:16
   |
16 |     for index, letter in builtins.enumerate(letters):
17 |         print(letters[index])  # PLR1736
18 |         blah = letters[index]  # PLR1736
   |                ^^^^^^^^^^^^^^
19 |         assert letters[index]  == "d"  # PLR1736
   |
help: Use the loop variable directly
   |
17 |         print(letters[index])  # PLR1736
   -         blah = letters[index]  # PLR1736
18 +         blah = letter  # PLR1736
19 |         assert letters[index]  == "d"  # PLR1736
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:19:16
   |
17 |         print(letters[index])  # PLR1736
18 |         blah = letters[index]  # PLR1736
19 |         assert letters[index]  == "d"  # PLR1736
   |                ^^^^^^^^^^^^^^
   |
help: Use the loop variable directly
   |
18 |         blah = letters[index]  # PLR1736
   -         assert letters[index]  == "d"  # PLR1736
19 +         assert letter  == "d"  # PLR1736
20 |
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:74:15
   |
72 |     # PLR1736
73 |     for index, list_item in enumerate(some_list, start=0):
74 |         print(some_list[index])
   |               ^^^^^^^^^^^^^^^^
75 |
76 |     # PLR1736
   |
help: Use the loop variable directly
   |
73 |     for index, list_item in enumerate(some_list, start=0):
   -         print(some_list[index])
74 +         print(list_item)
75 |
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:78:15
   |
76 |     # PLR1736
77 |     for index, list_item in enumerate(some_list):
78 |         print(some_list[index])
   |               ^^^^^^^^^^^^^^^^
   |
help: Use the loop variable directly
   |
77 |     for index, list_item in enumerate(some_list):
   -         print(some_list[index])
78 +         print(list_item)
79 |
   |

PLR1736 [*] List index lookup in `enumerate()` loop
  --> unnecessary_list_index_lookup.py:85:18
   |
83 |     column_names = ["a", "b"]
84 |     for index, column_name in enumerate(column_names):
85 |         _ = data[column_names[index]]  # PLR1736
   |                  ^^^^^^^^^^^^^^^^^^^
   |
help: Use the loop variable directly
   |
84 |     for index, column_name in enumerate(column_names):
   -         _ = data[column_names[index]]  # PLR1736
85 +         _ = data[column_name]  # PLR1736
   |
