python_exercises/thinkcspy/Chapter-10-Exercises/Problem12.py

21 lines
481 B
Python
Raw Permalink Normal View History

2023-10-19 14:52:00 -06:00
# Runestone.Academy thinkcspy course
# Chapter 10
# Problem 12
def count(lst):
# your code here
wordCount = 0
for item in lst:
if type(item) is str:
if item != "sam":
wordCount += 1
else:
wordCount += 1
return wordCount
return wordCount
myList = ["apple", 5, 6, True, "purple", False, "mushroom", 11, "gen-x", "sam", 7, 10, "cause", "interim"]
print(count(myList))