Feb-17-2021, 09:57 AM
(Feb-16-2021, 04:25 PM)Serafim Wrote: Note that, if "Sam" is not in the list, you get the length of the list as result.
This, however, gives "None" if "Sam" is missing:
def count_to_sam(samlist): if "Sam" not in samlist: return None else: return samlist.index("Sam") + 1 lst = ["able","been","state","Sam","beer"] print(count_to_sam(lst)) another_list = ["able","been","state","Tom","beer"] print(count_to_sam(another_list))
Output:4 None
Hello Serafim
Thanks for the update, much appreciated and I will study this along with other information that I have received. Thanks again