2022-11-13 10:39:28 -08:00

12 lines
226 B
Python

>>> for i, e in enumerate(a):
... if e == "cat":
... print(f"Found the cat at index {i}!")
... break
... else:
... print(f"a[{i}] = {e}")
...
a[0] = ant
a[1] = bat
Found the cat at index 2!
>>>