This piece of code should accept string input and output another string, which is only a modified version of the input string. I can not make it work.
It is supposed to print a line in which each letter is the next letter of the input string. But after running the code, it simply displays the same input string instead of the modified string.
def str_changer(string):
string_list = list(string)
alphabets = 'abcdefghijklmnopqrstuvwxyz'
positions = []
for letter in string_list:
positions.append(alphabets.index(letter))
for each in positions:
each = each + 1
for each in string_list:
string_list[string_list.index(each)] =
alphabets[positions[string_list.index(each)]]
another = ''.join(string_list)
return another
lmao = raw_input('Enter somin\'')
print str_changer(lmao)
source
share