8. Unsure why there is an error



So i'm unsure why this error message appears: Oops, try again. Does your anti_vowel function take exactly one argument (a string)? Your code threw a "'type' object has no attribute 'getitem'" error.

I'm quite sure the logic of my code makes sense, but I'm unsure if there is some other kind of mistake.

def anti_vowel(text):
    #Removes all uppercase characters
    #Make a list of vowels
    vowels = ["aeiouAEIOU"]
    #Find out how long the text is
    lenght = len(text)
    value = 0
    #Split up induvidual characters
    text = list[text]
    #Return the characters
    while char in text <= lenght:
        if text[value] not in vowels:
            return text[value]
            value += 1
            return ""


list is a built in function, but functions use ():

text = list(text)

not square brackets, that is used for accessing list/strings by index.

Why do you use a while loop here:

while char in text <= lenght:

use a for loop, a much better idea

A function ends the moment a return keyword is reached. Which in your case happens pretty quickly. You might want to change this

After you implanted this change, try further yourself first, if you need more help post an updated version of your code


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