195k views
3 votes
Look at the following Python code:

word1 = "Umpire"
word2 = word1[0:3]

Which characters will be sliced from word1 and assigned to word2?

Ump
Umpi
mpi
pire

User Ulak Blade
by
7.2k points

1 Answer

4 votes

Ump will be assigned to word2

word1[0:3] gets all of the letters from index 0 to index 3 exclusive (that means index 3 is not included)

User Kbariotis
by
8.2k points