+ 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")
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
+ 4
Msawenkosi Zuma ,
ok, not clear what your question is ???
+ 4
Simon Sauter ,
thanks!
yes you are right about the capital letters. i have overseen this
+ 2
Thank you so much @Lothar
+ 1
Lothar since you're using .lower() you don't need the capital letters in vowels.
0
Is there a particular reason why you posted this twice?
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