I am trying to replace different letters of the alphabet for a value: vowels are 1; "b", "g", "r" or "x" are 3 and the rest of the alphabet equals 5 (this is each character).
I've tried to use convert_text and sum but both didn't work. Also, if there is a way of simplyfing "rest" (all characters - vowel - points) would be appreciated!
I'm new at this, so thank you for your help!
convert_text = input("Enter a string: ")
vowel= "a" or "e" or "i" or "o" or "u"
points= "b" or "g" or "r" or "x"
rest= ¡ "c" or "d" "f" or "h" or "j" or "k" or "l" or "m" or "n" or "p" or "q" or "t" or "s" or "u"or "v" or "w" or"y" or "z"
replacements= {vowel:1, points:3, rest:5}
converted_text = input.sub('(\d+)', lambda m: replacements[m.group()], sentence)
print(converted_text)
For example "hello" would translate to 17 or "overflow" into 26. Thanks again!