What does it mean by 4?

Screen Link: Learn data science with Python and R projects

My Code:
row_1 = [‘Facebook’, 0.0, ‘USD’, 2974676, 3.5]
row_2 = [‘Instagram’, 0.0, ‘USD’, 2161558, 4.5]
row_3 = [‘Clash of Clans’, 0.0, ‘USD’, 2130805, 4.5]
row_4 = [‘Temple Run’, 0.0, ‘USD’, 1724546, 4.5]
row_5 = [‘Pandora - Music & Radio’, 0.0, ‘USD’, 1126879, 4.0]

first_4_fb = row_1[:4]
last_3_fb = row_1[-3:]
pandora_3_4 = row_5[2:4]

print(first_4_fb)
print(last_3_fb)
print(pandora_3_4)

output:
[‘Facebook’, 0.0, ‘USD’, 2974676]
[‘USD’, 2974676, 3.5]
[‘USD’, 1126879]

under the line 7 how as list slicing syntax shortcut “pandora_3_4 = row_5[2:4]” here 2:4 came! Ive already understood about the meaning 2 but not 4 :neutral_face:

This is explained in the content -

We retrieve the list slice we want by using the syntax a_list[m:n], where the following are true:

  • m represents the index number of the first element of the slice
  • n represents the index number of the last element of the slice plus one (if the last element has the index number 2, then n will be 3, if the last element has the index number 4, then n will be 5, and so on).

Is any of the above confusing you particularly? The image below the above in the content should also give you a better understanding of what’s going on. But if you have any questions let me know.