145k views
4 votes
Given that k refers to an int that is non-negative and that plist1 has been defined to be a list with at least k+1 elements, write a statement that defines plist2 to be a new list that contains all the elements from index k of plist1 and beyond. Do not modify plist1.

1 Answer

2 votes

Answer:

k = 3

plist1 = [10, 2, 0, 88, 190, 33, 1, 64]

plist2 = plist1[k:]

print(plist2)

Step-by-step explanation:

Initialize the k as 3

Initialize the plist1 that contains at least k+1 numbers

Slice the plist1 starting from index k until the end of the list, and set it to a new list called plist2

Print the plist2

User Kgothatso Kurt
by
4.9k points