+ 1

Write a function that takes in a string and then prints out all the vowels in the string. Make sure it can deal with capital let

My cod: def vowel(text): vowels = "aeiuoAEIOU" print([letter for letter in text if letter in vowels]) vowel("Beautiful")

4th Oct 2021, 7:37 PM
Msawenkosi Zuma
8 ответов
+ 5
Msawenkosi Zuma , i have used your code and reworked it slightly: [edited***] def vowel(text): vowels = "aeiuo" # *** removed the capital letters res = [letter for letter in text.lower() if letter in vowels] print(", ".join(res)) vowel("BeautiFUL") # result will be: e, a, u, i, u
4th Oct 2021, 8:11 PM
Lothar
Lothar - avatar
+ 4
Msawenkosi Zuma , ok, not clear what your question is ???
4th Oct 2021, 7:42 PM
Lothar
Lothar - avatar
+ 4
Simon Sauter , thanks! yes you are right about the capital letters. i have overseen this
5th Oct 2021, 1:54 PM
Lothar
Lothar - avatar
4th Oct 2021, 8:06 PM
Simon Sauter
Simon Sauter - avatar
+ 2
Thank you so much @Lothar
4th Oct 2021, 8:21 PM
Msawenkosi Zuma
+ 1
Lothar since you're using .lower() you don't need the capital letters in vowels.
4th Oct 2021, 8:14 PM
Simon Sauter
Simon Sauter - avatar
0
Is there a particular reason why you posted this twice?
4th Oct 2021, 7:47 PM
Simon Sauter
Simon Sauter - avatar
0
@Simon Sauter the questions aren't the same though they are similar @Lothar capital letters must be converted to small letters and the square brackets must not be there and it must not be returned as a string
4th Oct 2021, 7:54 PM
Msawenkosi Zuma