It shows error


#1

it shows error
def anti_vowel(text):
x=''
for c in text:
if c not in "aeiouAEIOU":
x+=c
print x

anti_vowel("Hi my name is PAnky")


Anti_vowel boolean troubles and no print out
#2

The missing statement is return x.

    x = ''
    for c in text:
        if c not in "aeiouAEIOU":
            x += c
    return x

Now supposing strings are immutable, and lists are not. we could write,

    x = []
    for c in text:
        if c not in "aeiouAEIOU":
            x += [c]
    return ''.join(x)

#3

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