Q. What will be the output of the following code segment:
a. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)
b. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)
c. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)
Answer :-
a = [1, 2, 3]
b = [6, 7, 8, 9, 10]
c = [2, 4, 6, 8, 10]
myList = [1,2,3,4,5,6,7,8,9,10]
ReplyDeleteprint(myList[ 7 : -1 ])
[8,9]
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )