Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python string assignment by index

# Strings are immutable in python, so you cannot insert characters.

# You could do convert it to a list however:
  
text = "Hello Warld"

text = list(text)
text[7] = "o"
text = "".join(text)

>>>text
"Hello World"
 
PREVIOUS NEXT
Tagged: #python #string #assignment #index
ADD COMMENT
Topic
Name
7+7 =