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 -

r - Quantstrat logical error while running applySignals - missing value where TRUE/FALSE needed -