How to replace characters in a string in python -
how replace characters in string know exact indexes in python?
ex : name = "abcdefgh" need change odd index positions characters '$' character.
name = "a$c$e$g$"
(considered indexes bigin 0 )
name = "abcdefgh" namel = list(name) in range(len(namel)): if i%2==1: namel[i] = '$' name = ''.join(namel) print(name)
Comments
Post a Comment