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

Emilio Andere
Emilio Andere
495 Points

Disemvowel

How do I put a word in a function?

how do I delete a specific letter

disemvowel.py
def disemvowel(word):
    return word

is this correct?

def disemvowel(Emilo): disemvowel.remove(e, i, o) return Emilio

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! First, the challenge you are referring to is sending in a string. Remove is only available on a list. So if you want to use remove, you must convert the string they are sending to a list.

Secondly, the remove function, takes exactly one argument.

I have made a short example on how you can convert a word to a list and how you can remove a specific letter from a list. This will not be the entire solution to this problem. Also note, that if you choose to go this route, you need to find a way to loop through it without mutating it. I suggest making a copy of the list for these purposes. What you'll see printed out is a list of characters and not a word. The challenge expects you to return a string. So if you convert it to a list and then alter it you will then have to convert the results back to a string before you return it.

I highly suggest running this in workspaces.

def disemvowel(word):
  word = list(word)
  if(word[0] == 'T'):
    word.remove('T')
  print(word)

disemvowel("Treehouse")

Hope this helps! :sparkles: