74.2k views
4 votes
 myLIst = [1, 2, 45, 66, 77, 88]

White the line of code which will print 2nd element to 4th element in myList.

 myLIst = [1, 2, 45, 66, 77, 88] White the line of code which will print 2nd element-example-1
User Ashok
by
6.7k points

1 Answer

5 votes

Answer:

print(myList[1:4])

Step-by-step explanation:

Hi,

To print 2nd element to 4th element in myList, we can use the following line of code: print(myList[1:4]).

The basic construct in Python is list[start:end], which returns a new list containing the elements that start at start index (including the element at that position) and go up to end but not including the element at position end.

Good luck!

User Snorpey
by
7.6k points