Checking for an item in a list (if then statement) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Checking for an item in a list (if then statement) (/thread-19888.html) |
Checking for an item in a list (if then statement) - Sailnir - Jul-18-2019 I am very new to python. I am trying to check if the first letter of a word is a vowel or not and I have to do so using sets. Here is what I am trying but it isn't working. My_Word = "cat" First_Letter = My_Word[0] vowels = {'a', 'e', 'i', 'o', 'u'} if First_Letter in vowels == trueFrom there I get a syntax error. Any help? Got it... there was a ":" Go figure RE: Checking for an item in a list (if then statement) - ndc85430 - Jul-18-2019 The == true at the end of line 4 is redundant. That is, that line is more naturally writtenif First_Letter in vowels: which also reads quite nicely. |