title: Why does this code print infinite numbers?
body: <p>In this code, why when I put a string &quot;6&quot; instead of 6 in x1 = Chain (&quot;6&quot;), it prints an infinite number in execution?</p>
  <pre><code>class Chain:
      def __init__(self, n):
          self.n = n
          self.counter = 0
  
      def __next__(self):
          if self.counter != self.n:
              self.counter += 1
          else:
              raise StopIteration
          return self.counter
  
      def __iter__(self):
          return self
  
  
  x1 = Chain(&quot;6&quot;)
  
  for i in x1:
      print(i)
  </code></pre>