#Python code
#firstly, we define a new string,it's a poem ,a big string
bigstring=""""
Today I saw a butterfly,
as it floated in the air;
Its wings were spread in splendor,
Unaware that I was there.
""""
#secondly, we convert it to a list
biglist=bigstring.split(' ')
biglist[1]='you'
biglist[3]="one"
#convert it back
bigstring=''.join(biglist)
bigstring
Because list is mutable,each time we operate on it,no new object generated.So we have high performance.
No comments:
Post a Comment