Advertisements
Advertisements
Question
How will you delete a string in Python?
Short Note
Solution
Python will not allow deleting a particular character in a string. Whereas you can remove the entire string variable using the del command.
Example:
Code lines to delete a string variable
>>> str1=”How about you”
>>> print (str1)
How about you
>>> del str1
>>> print (str1)
NameError: name ‘str1’ is not defined
shaalaa.com
Modifying and Deleting Strings
Is there an error in this question or solution?