Guest User

Untitled

a guest
Oct 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. def name_to_ascii(antigo):
  2. vogais = {'a': range(224, 230), 'e': range(232, 235), 'i': range(236, 239) \
  3. , 'o': range(242, 246) + [240, 248], 'u': range(249, 252), 'c': 231}
  4. tmp = []
  5. for ch in antigo:
  6. if not is_ascii(ch):
  7. if ord(ch) in vogais['a']:
  8. tmp.append('a')
  9. elif ord(ch) in vogais['e']:
  10. tmp.append('e')
  11. elif ord(ch) in vogais['i']:
  12. tmp.append('i')
  13. elif ord(ch) in vogais['o']:
  14. tmp.append('o')
  15. elif ord(ch) in vogais['u']:
  16. tmp.append('u')
  17. elif ord(ch) == vogais['c']:
  18. tmp.append('c')
  19. else:
  20. print antigo
  21. print 'Erro: {0} ({1})'.format(ch, ord(ch))
  22. exit(1)
  23. else:
  24. tmp.append(ch)
  25. novo = ''.join(tmp)
  26. print 'Antigo: {0}'.format(antigo)
  27. print 'Novo: {0}'.format(novo)
  28. print '-'
Add Comment
Please, Sign In to add comment