logo-MindMajix
PostPythonPython
T
Tim Parker

Posted on 19th July 2024|20 views

0
votes

Int Object Is Not Iterable

How can I resolve the error “‘int’ object is not iterable” in python?

I am working on the counting problem which is showing me the error here is the code:

def count(seq, itm):

    found = 0

    for j in len(sequence):

        if seq[j] == itm:

           found = found + 1

    return found

 

1 answers
Answers
P
sreelu 123

Posted on 19th July 2024| views

You just forgot to use range in the for loop modify the for loop like this, and it will work

For j in range(len(sequence))

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number