ProgrammingModerateProduct-company MCQ pattern

What is printed?

What is printed?
s = "  Py Thon  "
print(s.strip().lower().replace(" ", "").count("o"), s.split(" ").count(""))
  1. A. 1 0
  2. B. 1 4
  3. C. 2 4
  4. D. 1 2

Correct answer: B. 1 4

strip, lower and replace give "python", which has one 'o'. split(" ") with an explicit separator does NOT merge spaces: " Py Thon " becomes ['', '', 'Py', 'Thon', '', ''], which has 4 empty strings.

More Python Programming questions

Exams that ask this topic