Answers for "how to print first 2 element of list in python"

7

python first n elements of list

a=list((1, 2, 3))
n=1
a[:n]

output:
[1]
Posted by: Guest on October-15-2020
0

how to take first half of list python

Use the slicing syntax list[:middle_index] to get the first half of the list 
and list[middle_index:] to get the second half of the list.
Posted by: Guest on August-11-2020

Code answers related to "how to print first 2 element of list in python"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language