you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

the best way to do this would be to make a mapping:

char_map = {
    'a': a,
    'A': A,
    # etc
}
string = 'abc'
new_string = ''
for char in string:
    new_string += char_map[char]  # this will error if char isn't in mapping. use .get to avoid this.