How do I use the index of a for
loop in Python?
I'm trying to use .items()
, but I did not succeed.
I know this is very basic. But I'm not getting it. I'm migrating from php to python and am encountering a few different things. Thank you
for index, linha in reg2.items():
print(index, linha)
Error:
for index, linha in reg2.items()
AttributeError: 'list' object has no attribute 'items'
items
is used fordicts
, you have alist
. Given your current code, you're probably looking for enumerate