QuestionQ6

Strings

What behavior is expected from the following code?

Question Image

  • A it outputs 123
  • B it raises an exception
  • C it outputs 6
  • D it outputs 321
Explanation

reversed(string) produces the characters '3', '2', and '1'. Each is converted to an integer and added to dummy, so the printed total is 6.

Community Discussion

No comments yet. Be the first to start the discussion!