Counting iterations

Fredrik Lundh fredrik at pythonware.com
Sat Apr 9 04:50:19 EDT 2005


Derek Basch wrote:

> ooops you are right. Should have been:
>
> pets = ["cat", "dog", "bird"]
> num_pets = 0
> for i in pets:
>    num_pets += 1
>    print "pet" + "#" + num_pets

Traceback (most recent call last):
  File "example.py", line 5, in ?
    print "pet" + "#" + num_pets
TypeError: cannot concatenate 'str' and 'int' objects

</F> 






More information about the Python-list mailing list