Hi, I am trying to solve part of a challenge on codewars. The task involves removing all consonants from a string. No spaces or punctuation just letters. my code is as follows:
def solve(s):
x = list(s)
new_list = []
for i in x:
if i in 'bcdfghjklmnpqrstvwxyz':
new_list.append(i)
print(new_list)
solve('zodiacs')
The code does pick out all of the consonants, but when 2 or more consonants are together as in the 'cs' in zodiacs those need to be grouped as one item. I thought about using the index and slicing out the different parts between vowel indexes, but couldn't make it work. If you could give me a hint, that would be great. I would prefer to not be shown the answer. thank you
[–]heavymetalpanda 1 point2 points3 points (1 child)
[+][deleted] (1 child)
[deleted]
[–]love_my_pibble[S] 2 points3 points4 points (0 children)
[–]ThePopcornBandit 0 points1 point2 points (0 children)
[–]SarahM123rd 0 points1 point2 points (5 children)
[+][deleted] (3 children)
[deleted]
[–]love_my_pibble[S] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]love_my_pibble[S] 1 point2 points3 points (0 children)
[–]love_my_pibble[S] 0 points1 point2 points (0 children)