I've searched on how to do this in python and I can't find an answer. If you have a string:
>>> value = 'abc'
>>> value = 'bcd'
>>> value = 'a'
>>> print (chr(ord(value)+1))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ord() expected a character, but string of length 3 found
You could use a generator expression with
''.join() as follows:
In : value = 'abc' In : value_altered = ''.join(chr(ord(letter)+1) for letter in value) In : value_altered Out: '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.