Advertisement
brianMc

Python String Replace

Aug 26th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. def replacer(word):
  2.     vowels = ('a', 'e', 'i', 'o', 'u')
  3.     const = ('b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z')
  4.     for c in word:
  5.         if c.lower() in vowels:
  6.             word = word.replace(c,"#")
  7.         if c.lower() in const:
  8.             word = word.replace(c,"@")
  9.     print(word)
  10.  
  11. name = raw_input('Enter your name: ')
  12. replacer(name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement