RosettaCodeData/Task/Search-a-list/Python/search-a-list-1.py

8 lines
238 B
Python

haystack=["Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"]
for needle in ("Washington","Bush"):
try:
print haystack.index(needle), needle
except ValueError, value_error:
print needle,"is not in haystack"