''' Purpose: use if-else statement ''' # define helpful constant VOWELS = "aeiou" # all caps tells us we should never change this, so we should never say VOWELS = ... anything # defining constants in all caps is a style choice for Python, there is nothing special about it # there are tools that will check variable names and see if you've ever changed it # python/pycharm does not care if constants are defined in all uppercase # get input text and put into canonical form text = input( 'Enter text: ' ) text = text.strip() # remove leading and trailing whitespace so first character is not whitespace text = text.lower() # lowercase so we don't have to check capital and lowercase vowels # determine its first character first_character = text[ 0 ] # grab the first character of our cleaned up string # don't worry about variable name length, take advantage of pycharm autocomplete # determine whether first character is a vowel if ( first_character in VOWELS ) : # condition/test expression goes in parentheses - what are you checking? # if ( first_character == "a" or first_character == "e" or first_character == "i" or first_character == "o" or # first_character == "u" ) will work as well # if ( first_character == "a" or "e" ) will not work, it will always evaluate to True because "e" is always True # ( everything is True except 0 and "" ) # ** best way to check against multiple values is to have a list/string and use the in operator ** # ** parentheses are unnecessary in Python, but it's good practice for other programming languages + CS 1112 style rule** # the test expression is going to evaluate to True or False # how does the in operator work? # probably uses the count function and checks if the value is >= 1 # first_character in VOWELS is going to evaluate to True or False. # either the first_character is in VOWELS or it is not # this would work the same if VOWELS = [ "a" , "e" , "i" , "o" , "u" ] print( "Text begins with vowel" ) # if condition is True, execute this line else : print("Text does not begin with vowel") # if condition is False, execute this line # alternate using elif: # if ( first_character == "a" ) # ... # elif (first_character == "e" ) and so on