RenzCutie

NameTricks

Nov 13th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. def isVowel(l):
  2.     if l == "a" or l == "A" or l == "e" or l == "E" or l == "i" or l == "I" or l == "o" or l == "O" or l == "u" or l == "U":
  3.         return True
  4.     else:
  5.         return False
  6.  
  7. inStr = input("Enter Name: ")
  8.  
  9. inStrE  = inStr.split(" ")
  10. inStrDictVow = {}
  11. inStrDictCons = {}
  12.  
  13. vowels = []
  14. consonants = []
  15.  
  16. for l in inStr:
  17.     if l == " ":
  18.         continue
  19.     if isVowel(l):
  20.         if l in inStrDictVow.keys():
  21.             inStrDictVow[l] += 1
  22.         else:
  23.             inStrDictVow.update({l:1})
  24.     else:
  25.         if l in inStrDictCons.keys():
  26.             inStrDictCons[l] += 1
  27.         else:
  28.             inStrDictCons.update({l:1})
  29.        
  30.  
  31. for v in inStrDictVow.keys():
  32.     vowels.append(v)
  33.  
  34. for c in inStrDictCons.keys():
  35.     consonants.append(c)
  36.  
  37. print("Name: %s" % inStr)
  38. print("Vowels: %s" % vowels)
  39. print("Consonants: %s" % consonants)
  40.  
  41. cnt = -1
  42. Vows = {}
  43. for y in inStr:
  44.         cnt += 1
  45.         if isVowel(y):
  46.             if y in Vows.keys():
  47.                 continue
  48.             Vows.update({y:cnt})
  49.             x = ""
  50.             z = ""
  51.             print("Vowels: %s:%s" % (y,Vows[y]), end=", ")
  52.             try:
  53.                 x =  inStr[cnt*2]
  54.                 z = cnt*2
  55.             except:
  56.                 print("No Consonant associated")
  57.                 break
  58.             print("Consonant: %s:%s" % (x,z))
  59.            
  60. print("Indexception Total: %i" % (int(len(inStr)) + 1))            
  61. #Marc Reinhard Canlas Ballon
  62.        
  63.  
  64.                
  65.        
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment