Feb-16-2021, 03:58 PM
lst = ["able","been","state","Sam","beer"] def count_to_sam(samlist): #better name for function return_count = 0 #this will be the count of words for element in samlist: #loop is in the function return_count = return_count+1 #or use return_count += 1 if element == "Sam": break return return_count #function returns the count print(count_to_sam(lst))