+ 1
How could I modify this code to make it valid for duplicate vowels?
the_string= input("Please enter a string") count=0 if "a" in the_string or "A" in the_string: count+=1 if "e" in the_string or "E" in the_string: count+=1 if "i" in the_string or "I" in the_string: count+=1 if "o" in the_string or "O" in the_string: count+=1 if "u" in the_string or "U" in the_string: count+=1 if count==0: print("Your string has zero vowels") elif count==1: print("Your string has one vowel") else: print("Your string has",count, "vowels")
2 ответов
+ 4
for i in the_string:
if i in "AEIOU":
count+=1
Then your prints.
+ 1
you also need to do:-
the_string= input("Please enter a string").upper()
# or
for i in the_string.upper()
# or
if i in "AEIOUaeiou":