I was looking for how to do this in python and I cannot find the answer. If you have a line:
>>> value = 'abc'
How would you increase all characters in a string by 1? So the input I'm looking for is:
>>> value = 'bcd'
I know that I can do this with a single character using ord and chr:
>>> value = 'a' >>> print (chr(ord(value)+1)) >>> b
But ord()
and chr()
can only take one character. If I used the same statement above with a string of more than one character. I would get an error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ord() expected a character, but string of length 3 found
Is there any way to do this?
source share