Multiple choice

What would this function output? def value(a, b): return a[:b] print value("Notebook",5)

  1. ook

  2. Noteb

  3. book

  4. noteb

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The slice 'a[:5]' on the string 'Notebook' takes the characters from index 0 up to, but not including, index 5. This results in the first five characters: 'N', 'o', 't', 'e', 'b'.