Skip to content

Question 4

The following Python expression is entered into a fresh Python shell with no prior import statements. Determine the result from evaluating the following expression. [3 marks]

print(len('Kevin and Onion King'))
Solution

The len() function here measures the length of an iterable - in this case, a string. Count all the characters including spaces inside the string.

Answer
20