Skip to content

Instantly share code, notes, and snippets.

@RikerW
Created January 9, 2018 00:00
Show Gist options
  • Save RikerW/adfdbba2c2110b96fadccd2668595f34 to your computer and use it in GitHub Desktop.
Save RikerW/adfdbba2c2110b96fadccd2668595f34 to your computer and use it in GitHub Desktop.
n=raw_input()
1/n.isalpha()
x=sum([1if i in'aeiou'else 0for i in list(n.lower())])
print'Vowels: '+`x`,'Consonants'+`len(n)-x`
# line breakdown:
n=raw_input() # get input, assign to n
1/n.isalpha() # make sure n is only letters, since 1/false evaluates to 1/0 which is an error
x=sum([1if i in'aeiou'else 0for i in list(n.lower())]) # count vowels, and yes "1if" and "0for" are valid syntax
print'Vowels: '+`x`,'Consonants'+`len(n)-x` # print output, formatted nicely, `x` is shorthand for repr(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment