Python: Delete a character from a string -


i want delete i.e. character number 5 in string. did:

del line[5]

and got: typeerror: 'str' object doesn't support item deletion

so no wonder whether there different efficient solution problem.

strings immutable in python, can't change them in-place.

but of course can assign combination of string slices same identifier:

mystr = mystr[:5] + mystr[6:] 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -