Why won't this code search if wordToList[0] is a vowel?

Question:

def ecrypt(w):
    vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
    wordToList = list(w)
    if (wordToList[0] == vowels):
        w = w + "-way"
    return w

In this code, i’m trying to figure out if the first item in wordToList is a vowel.

Asked By: micheal cay

||

Answers:

== is an equality operator. Usually used to compare objects.

To check if an item is present in a list, use the in keyword.

Example:

if (word_to_list[0] in vowels):
    print('Found a vowel')
Answered By: Vishnudev
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.