DEV Community

Discussion on: 30 Days of Python 👨‍💻 - Day 3 - Data Types II

Collapse
 
pantogil profile image
pantogil

Hello, as always, you explain very well, I continue learning from your examples, I have a doubt, about Immutability:

Ropes are immutable in nature. It means that the value of a string cannot be altered or modified. My question is with the (insert) method, can't I add data to a string?

Collapse
 
arindamdawn profile image
Arindam Dawn

Hi. Can you provide an example based on your question? It would be easier for me to understand your doubt then.
The value of a string cannot be mutated
for eg if we try to do something like this

sample = 'hello'
sample[0]='p'
print(sample[0])

It will result in an error

Collapse
 
pantogil profile image
pantogil

Hello, it was a confusion that I had, I apologize, with the next class I clarified the doubts