-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheasy-04-letter-changes.py
More file actions
27 lines (23 loc) · 927 Bytes
/
easy-04-letter-changes.py
File metadata and controls
27 lines (23 loc) · 927 Bytes
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
# Have the function LetterChanges(str) take the str parameter being passed and
# modify it using the following algorithm. Replace every letter in the string
# with the letter following it in the alphabet (ie. c becomes d, z becomes a).
# Then capitalize every vowel in this new string (a, e, i, o, u) and finally
# return this modified string.
def LetterChanges(stre):
rv_str = ""
vowels = ['a', 'e', 'i', 'o', 'u']
for letter in stre:
if ord('a') <= ord(letter) and ord(letter) < ord('z'):
ch_str = ord(letter) + 1
if ch_str in map(ord, vowels):
rv_str += chr(ch_str - 32)
else:
rv_str += chr(ch_str)
elif letter == 'z':
rv_str += 'A'
else:
rv_str += letter
return rv_str
# keep this function call here
# to see how to enter arguments in Python scroll down
print LetterChanges(raw_input())