Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Practice InterviewNew Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Python Interview Questions and Answers

Ques. How do I modify a string in place?
Ans. You can\'t, because strings are immutable. If you need an object with this ability, try converting the string to a list or use the array module:
>>> s = \"Hello, world\" >>> a = list(s)
>>>print a
[\'H\', \'e\', \'l\', \'l\', \'o\', \',\', \' \', \'w\', \'o\', \'r\', \'l\', \'d\'] >>> a[7:] = list(\"there!\")
\'Hello, there!\'
>>> import array
>>> a = array.array(\'c\', s) >>> print a
array(\'c\', \'Hello, world\')
>>> a[0] = \'y\' ; print a
array(\'c\', \'yello world\')
>>> a.tostring()
\'yello, world\'
Is it helpful? Yes No

Most helpful rated by users:

©2019 WithoutBook