python - Altering characters in strings -
code = ['#+/084&"', '#3*#%#+', '8%203:', ',1$&', '!-*%', '.#7&33&', '#*#71%', ''] how can alter list if ,for example, want change of '#' 'd', list appear such:
code = ['d+/084&"', 'd3*d%d+', '8%203:', ',1$&', '!-*%', '.d7&33&', 'd*d71%', '']
you can map replace operation list:
map(lambda x: str.replace(x, '#', 'd'), code) if in python 3 might need:
list(map(lambda x: str.replace(x, '#', 'd'), code))
Comments
Post a Comment