I want to delete i.e. character number 5 in a string. So I did:
del line[5]
and got:
TypeError: ‘str’ object doesn’t support item deletion
So no I wonder whether there is a different efficient solution to the problem.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Strings are immutable in Python, so you can’t change them in-place.
But of course you can assign a combination of string slices back to the same identifier: