-3

Let's say I have a program that generates lists

list1 = [a, b, c, d, e, f, g]
list2 = [a, b, c, d, e, f, g, h, i, j, k, l, m]
list3 = [a, b, c, d, e, f, g, h, i, j, k, l, m, o, p]

how can i write a piece of code that extracts all the items from a given index all the way to the end and assigns them to a new variable?

For example, if I want to get all the items from index 3 to the end of the list of list3 and assign them to list4

list4 = [d, e, f, g, h, i, j, k, l, m, o, p]

I am repeating myself when I say 'to the end' beacuse I need something that works for all the lists that variy in ranges.

Carlos Mediavilla
  • 184
  • 1
  • 1
  • 14

1 Answers1

0

The solution is very simple:

list4 = list3[3:]
Ernst
  • 514
  • 10
  • 26