Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (2016, retired 2019) Lists Disemvowel

disemvowel() missing 1 required positional argument: 'v'

this code is working fine on workspace but i keep error

disemvowel.py
word_list=[]
vowel_list = ['A','a','E','e','I','i','O','o','U','u']
def disemvowel(w,v):  
    for i in vowel_list:
        for j in word_list:
            if i == j:
                word_list.remove(j)
    return(word_list)    

def word_split(text):
    for letter in range(0,len(text)):
        word_list.append(text[letter])
        if letter == 'i':  
            letter +=1     

text = "fariba"
word_split(text)
disemvowel(vowel_list, word_list) 

3 Answers

Louise St. Germain
Louise St. Germain
19,424 Points

Hi Mina,

Good work so far! The code is valid, but the problem is that it is not set up the way the challenge is asking for, so that's why it is not passing the challenge.

There are a couple of things you will need to adjust:

First, the challenge is going to test your code by attempting to call the disemvowel function with one parameter, which is the the word (a string, not a list) it wants to remove vowels from. Your code, however, is set up so that you need to run word_split() first, and pass two arguments (both lists) to disemvowel. Because of this, when the challenge tries to call disemvowel directly with one string, it causes an error. You will need to modify the code so that everything happens inside the disemvowel function. You could probably have a call to word_split from within disemvowel if you want, but you'll need to make sure disemvowel only has one parameter. It should also be where the process starts. In summary:

# What you have:
def disemvowel(word_list, vowel_list):
     # stuff...

# What the challenge is expecting:
def disemvowel(word_string):
    # stuff...

The other thing I wanted to mention is that the output of disemvowel should be a string, similar to the original input. Right now, you are returning a list, which is not quite the right format - you'll need to re-assemble it into a string. For example, disemvowel("children") should return "chldrn" and not ["c", "h", "l", "d", "r", "n"].

As a side note, this extra code outside the functions is fine for testing in workspaces or whatever text editor you're using, but should not be included in the challenge. Just the disemvowel function is needed. The challenge will take care of coming up with a string, and making the call to disemvowel.

text = "fariba"
word_split(text)
disemvowel(vowel_list, word_list) 

I hope this helps! Give this another try, and let me know how it goes! :-)

thanks , finally it went through

Thanks for your help , i fixed my code but i have another error coming ==> Bummer: Hmm, got back letters I wasn't expecting! Called disemvowel('AiDxBCm') and expected 'DxBCm'. Got back 'kyXcDxBCm'

word_list=[]
vowel_list = ['A','a','E','e','I','i','O','o','U','u']

def disemvowel(text):
    for letter in range(0,len(text)):
        word_list.append(text[letter])
        if letter == 'i':  
            letter +=1     
    for i in vowel_list:
        for j in word_list:
            if i == j:
                word_list.remove(j)
    word_string = "".join(word_list)
    return(word_string)
Louise St. Germain
Louise St. Germain
19,424 Points

Hi Mina!

You're basically there! The only thing is that because of the way the challenge is set up, it's only running the disemvowel function, and doesn't load anything else in the file, which includes the word list and the vowel list you set up before disemvowel. If you put those inside disemvowel (see below), everything should work!

def disemvowel(text):

    # Move these two lines inside the function
    word_list=[]
    vowel_list = ['A','a','E','e','I','i','O','o','U','u']

    for letter in range(0,len(text)):
        word_list.append(text[letter])
        if letter == 'i':  
            letter +=1     
    for i in vowel_list:
        for j in word_list:
            if i == j:
                word_list.remove(j)
    word_string = "".join(word_list)
    return(word_string)

Give it a try and let me know if there are still any problems.