Anti_vowel, problem with adding spaces


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096


It outputs the words without the vowels, but without the spaces as well. This has been boggling my mind for hours. This is what I've come up with so far, but there's a missing piece. Hope you can help and thank you in advance!


def anti_vowel(text):
    vowels = "a, A, e, E, i, I, o, O, u, U" #list of vowels to avoidus
    text_list = []
    
    #for words in text:
    for letters in text:
        if letters not in vowels:
            text_list.append(letters) #Appends each letter to list
    return "".join(text_list)
    
print anti_vowel("Hey you fucking pansy")


#2

do you see the "".join()? the character between the "" indicate what to join with, in your case it is nothing, you could also tell join to use spaces to join?

" ".join()

#3

Same problem as OP.. tried concatenating strings as well as appending letters to the list, but no matter what I do, it still won't return/print with spaces. Could you ellaborate please on "tell join to use spaces to join" please?

Thanks


#5

i made a horrible mistake, this join as done by OP is right:

return "".join(text_list)

the problem for you that in the variable allvowels (and for OP in vowels), you included spaces and ,, so that is now also removed. Your string allvowels, so just contain the vowels, and that is it: allvowels = "aeiou" and so on. everything that is in that string, is not included in the finalprint list


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.