12 lines
226 B
Python
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!
|
|
>>>
|