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

Popular posts from this blog

apache - setting document root in antoher partition on ubuntu -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -