ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print('xxhixx'.strip('x') + '|' + 'abc'.strip('ac'))
  1. A. xxhixx|b
  2. B. hi|b
  3. C. hi|abc
  4. D. hi|ac

Correct answer: B. hi|b

strip with an argument removes any of the listed characters from both ends. The x characters go from the ends of xxhixx, and a and c are removed from abc, leaving b.

More Python Programming questions

Exams that ask this topic