This's my code i know how to pass this practice by other code i just wanna know what's wrong with my code , and how can i modify my code?


Line 2: `text = str(text)

text is already a string. No need to convert, so that line may be removed.

Line 3: i = { ... }

This should be a list, as in,

i = [ ... ]

Line 4 is fine.

LIne 5: if x == i:

It will never equal to i, since it is only one letter being compared to a list. I believe you are looking for the in operator in this case:

if x in i:

Line 6: `text.replace( ... )

This is risky business because it mutates the string we are iterating. Not going to result in what we might expect. This has been discussed in the forums so dig around for the explanation(s).

The .replace() method is very possibly greedy which means it takes out all that it sees. This bears proving out. However, I do not believe that method has come up in the previous 8 units so should not be used in the solution for this practice.

If one were to use it, though, all we would need to do is iterate over i.

>>> v = 'aeiou'
>>> text = 'the shores of Old Woman Bay'
>>> for x in v:
	text = text.replace(x, '').replace(x.upper(), '')
>>> text
'th shrs f ld Wmn By'

But as mentioned, this is disqualified as a practice makes perfect solution since it goes beyond what has been learned so far. Try finding a solution that uses only what has been taught up to now in the first 8 units.


Thank you very much
Thanks for you patience!!!
i really learn a lot from you every explanations in detail
Thank you again!