-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring character changer.py
58 lines (48 loc) · 1.07 KB
/
string character changer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Have the function StringChallenge(str), take the str parameter being passed and modify
it using the following algorithm. Replace every letter in the string with the following
in the alphabet. Then capitalize every vowel in this new stringand finally return this
modified string.
Example:
Input: hello*3
Output: Ifmmp*3
Input: fun times!
Output: gvO Ujnft!
"""
import re
def StringChallenge(strParam):
replaceCaharacters = {
'a': 'b',
'b': 'c',
'c': 'd',
'd': 'E',
'e': 'f',
'f': 'g',
'g': 'h',
'h': 'I',
'i': 'j',
'j': 'k',
'k': 'l',
'l': 'm',
'm': 'n',
'n': 'O',
'o': 'p',
'p': 'q',
'q': 'r',
'r': 's',
's': 't',
't': 'U',
'u': 'v',
'v': 'w',
'w': 'x',
'x': 'y',
'y': 'z',
'z': 'A',
}
newString = re.sub(r"[abcdefghijklmnopqrstuvWxyz]", lambda x: replaceCaharacters[x.group(0)], strParam)
return newString
print(StringChallenge(input()))
"""
Result
Success
"""