Created
July 16, 2019 15:17
-
-
Save cibofdevs/28cb22241ab9f69ebf4b5b1f4121e9e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write code to count the number of strings in list items that have the character w in it. | |
# Assign that number to the variable acc_num. | |
# HINT 1: Use the accumulation pattern! | |
# HINT 2: the in operator checks whether a substring is present in a string. | |
# Hard-coded answers will receive no credit. | |
items = ["whirring", "wow!", "calendar", "wry", "glass", "", "llama","tumultuous","owing"] | |
acc_num = 0 | |
for i in items: | |
if 'w' in i: | |
acc_num += 1 | |
print(acc_num) |
items = ["whirring", "wow!", "calendar", "wry", "glass", "", "llama","tumultuous","owing"]
acc_num=0
for i in items:
if i.count("w"):
acc_num+=1
words = sentence.split()
num_a_or_e = 0
for word in words:
if "a" in word[0:]:
print("mujju")
num_a_or_e += 1
elif "e" in word[0:]:
print("mujju")
num_a_or_e += 1
print(num_a_or_e)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
items = ["whirring", "wow!", "calendar", "wry", "glass", "", "llama","tumultuous","owing"]
acc_num=0
for i in items:
if "w" in i:
acc_num=acc_num+1
print(acc_num)