-2

So the goal is to count the number of words in the sentence with the letter 'w', and I have written the code to count the number of w's but I can't get it to count the words in total.

items = ["whirring", "wow!", "calendar", "wry", "glass", "", "llama","tumultuous","owing"]
items = str(items)
acc_num = 0
for i in items:
    if i in ['w']:
        acc_num += 1
print(items)
Lefteris Theodorou
  • 91
  • 1
  • 4
  • 12

1 Answers1

1

Just check if the letter w is in the word.

items = ["whirring", "wow!", "calendar", "wry", "glass", "", "llama","tumultuous","owing"]

count = 0
for i in items:
    if "w" in i:
        count +=1
Daniel
  • 5,095
  • 5
  • 35
  • 48