Assume I input list containing [1,2,3,4]. How do I make it so it returns another list only containing the first and last entry ([1,4]).
Asked
Active
Viewed 31 times
-5
-
That's not a list of lists - that's a list containing only part of the original list. – EJoshuaS - Stand with Ukraine Oct 16 '20 at 15:02
1 Answers
0
To returns another list only containing the first and last entry you may
a=[1,2,3,4]
b=[a[0], a[-1]]
b
[1, 4]

Heikki
- 2,214
- 19
- 34

yafizicist
- 1
- 2
-
Can you add more explanation to this? That would be helpful to the OP. – EJoshuaS - Stand with Ukraine Oct 16 '20 at 15:04