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

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

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