Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 556 Bytes

vowel_letters.md

File metadata and controls

22 lines (18 loc) · 556 Bytes

Vowel Letters

  1. Improve the following code
char = input("Insert a character: ")
if char == "a" or char == "o" or char == "e" or char =="u" or char == "i":
    print("It's a vowel!")

Solution

char = input("Insert a character: ") # For readablity
if lower(char[0]) in "aieou": # Takes care of multiple characters and separate cases
    print("It's a vowel!")

OR

if lower(input("Insert a character: ")[0]) in "aieou": # Takes care of multiple characters and small/Capital cases
    print("It's a vowel!")