How to shift all characters in a list of strings N places up in the ASCII table with Python

1 Answer

0 votes
def shiftUpNCharacters(s, N):
    return ''.join(chr(ord(char) + N) for char in s)
    
lst = ['python', 'java', '123', '!#$']

for s in lst:
    print(shiftUpNCharacters(s, 3))



'''
run:

s|wkrq
mdyd
456
$&'

'''

 



answered Feb 29, 2024 by avibootz
...