Created
February 19, 2020 18:44
-
-
Save mayankdawar/573da852688327648ca9025db6ae0e54 to your computer and use it in GitHub Desktop.
Write code that counts the number of words in sentence that contain either an “a” or an “e”. Store the result in the variable num_a_or_e. Note 1: be sure to not double-count words that contain both an a and an e. HINT 1: Use the in operator. HINT 2: You can either use or or elif. Hard-coded answers will receive no credit.
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
sentence = "python is a high level general purpose programming language that can be applied to many different classes of problems." | |
sen = sentence.split() | |
count = 0 | |
for i in sen: | |
if 'a' in i or 'e' in i: | |
count += 1 | |
num_a_or_e = count | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment