Question discussion

What is the output of the following Python code?print("ab" * 2 + "c".upper(), "a,b,,c".split(","))

1518Medium DSSSB TGT Computer Science 0 replies

What is the output of the following Python code?

print("ab" * 2 + "c".upper(), "a,b,,c".split(","))
  • AababC ['a', 'b', 'c']
  • BababC ['a', 'b', '', 'c']
  • CabcC ['a', 'b', '', 'c']
  • Dabab ['a', 'b', '', 'c']
Correct answer: B

Explanation

"ab" * 2 is "abab" and "c".upper() is "C"; splitting on commas keeps the empty string between the consecutive commas.

Discussion 0

Nobody has replied yet. Start the discussion!