I\'ve searched on how to do this in python and I can\'t find an answer. If you have a string:
>>> value = \'abc\'
How would you
You could use a generator expression with ''.join()
as follows:
In [153]: value = 'abc'
In [154]: value_altered = ''.join(chr(ord(letter)+1) for letter in value)
In [155]: value_altered
Out[155]: 'bcd'
The generator iterates over each letter
in the string value
and increments it by one using the chr(ord(letter)+1)
methodology suggested in your question. It then uses ''.join()
to convert the letters in the generator back into a string.