Python Strings · Question 18 · Hard

strip() is given a string of characters as its argument. What does this print?

print("www.logicwiz.ai".strip("w.ai"))
  1. logicwiz
  2. www.logicwiz
  3. ww.logicwiz
  4. www.logicwiz.ai
Answer and explanation

Answer: A. logicwiz

Explanation: The argument is a set of characters, not a prefix or suffix. From the left, w, w, w and the dot are removed until 'l' is met; from the right, i, a and the dot are removed until 'z' is met. What remains is logicwiz.

Previous: split() and rsplit() are each limited to one split. What does this print? · Next: Three pairs of strings are compared with the less-than operator. What is the…

Practise python strings

Try a fresh set of python strings questions with an explanation after every answer, free and without signing up: Python Strings practice. Or sit a full placement mock test.

More python strings questions

More python practice

Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge