'int' object is not iterable - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: 'int' object is not iterable (/thread-24542.html) |
'int' object is not iterable - el_bueno - Feb-18-2020 Hello Everyone! Why do I see the error ('int' object is not iterable) when I add the method list? list02=[a,b,c,d,e,f,g,h,i,j] for item,item1 in enumerate(list02): print(list(item))And thank you. RE: 'int' object is not iterable - michael1789 - Feb-18-2020 list() converts to a list, but an int only has one item and can't be a list. RE: 'int' object is not iterable - Larz60+ - Feb-18-2020 enumerate returns an index and a value; thus your code, item is an integer (index within list) and item 1 is the value at that index. in addition, your print is incorrect, print(item) will print the index, whereasprint(item1) will print the value of the element at index item
|