+ 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")

7th Dec 2019, 5:33 PM
Esteban Rueda
Esteban Rueda - avatar
2 ответов
+ 4
for i in the_string: if i in "AEIOU": count+=1 Then your prints.
7th Dec 2019, 5:39 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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":
7th Dec 2019, 8:25 PM
rodwynnejones
rodwynnejones - avatar