anti_vowel question


Hey, what exactly does the return str line do?

I see that it joins all the letters thrown into the letters list, but how does it return them with the proper spacing?

8. anti_vowel [solved]

In that line, str() actually does nothing, since the join() function returns a string. The spacing is preserved from the original string since only vowels are removed.


Thanks for replying. So, for example, if I put in "hello world", it returns "hll wrld". As it iterates over each letter, are the letters stored in the list like:

letters = ["h", "e", "l", "l", "o", "", "w", "o", "r", "l", "d"]

Vowels removed ->> join together and "" keeps the words separate, right?


a simple way to find out:

print "".join(letters)

the answer seems to be no, because of this bit:

"o", "", "w"

if between the o and w was a space (" ") rather then a empty string/character, then the result would have been hello world


Ok, I'm a little bit more clear now. But just to make sure, when you iterate over a string with a space, is the considered "" as opposed to " " like in the exercise?


If you for example use python.dan his code, spaces are stored ad " ", so when joining the string, words will have spaces in them

It is very simple, if hll wrld is returned, this:

letters = ["h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"]

is stored with a space in it, and when joined a space will be inserted in the string, simple