ProgrammingModerateAccenture · Capgemini pattern

What is printed?

What is printed?
s = "  Hello, World  "
print(s.strip().lower().split(","), s.count("l"), s.find("z"), "-".join("abc"))
  1. A. ['hello', 'world'] 3 -1 a-b-c
  2. B. ['hello', ' world'] 3 None a-b-c
  3. C. ['hello', ' world'] 2 -1 abc
  4. D. ['hello', ' world'] 3 -1 a-b-c

Correct answer: D. ['hello', ' world'] 3 -1 a-b-c

strip removes outer spaces, but split(",") keeps the space after the comma, giving ' world'. count is case-sensitive: three lowercase l's. find returns −1 when absent (index would raise ValueError). join puts the separator between the characters.

More Python Programming questions

Exams that ask this topic