Python Forum
'int' object is not iterable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'int' object is not iterable
#1
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.
Reply
#2
list() converts to a list, but an int only has one item and can't be a list.
Reply
#3
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, whereas
print(item1) will print the value of the element at index item
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Did you know that map() accepts more than one iterable? DeaD_EyE 2 663 Apr-13-2025, 10:16 AM
Last Post: noisefloor
Question TypeError: argument of type 'NoneType' is not iterable Tajaldeen 7 3,009 Nov-29-2024, 09:45 AM
Last Post: Tajaldeen
Question how to solve `'TypeError: 'int' object is not iterable`? netanelst 2 3,062 May-24-2022, 12:03 PM
Last Post: deanhystad
  Trying to understand how isinstance(values, collections.Iterable) work. quazirfan 7 6,941 Aug-10-2021, 08:10 AM
Last Post: snippsat
  Cannot unpack non-iterable NoneType object, i would like to ask for help on this. Jadiac 3 11,775 Oct-18-2020, 02:11 PM
Last Post: Jadiac
  subprogram issues: cannot unpack non-iterable function object error djwilson0495 13 9,193 Aug-20-2020, 05:53 PM
Last Post: deanhystad
  Why the result of "extended iterable unpacking" with set() is unpredictable? zohanlin 2 2,883 Jun-29-2020, 10:30 AM
Last Post: zohanlin
  TypeError: 're.Match' object is not iterable charlesauspicks 1 13,967 May-25-2020, 06:14 AM
Last Post: bowlofred
  function/nonetype object is not iterable nanok66 5 6,423 May-08-2020, 07:39 PM
Last Post: nanok66
  min() function in iterable index OokaydO 4 4,084 Apr-23-2020, 09:21 AM
Last Post: OokaydO

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020