get the first element of array in python
Code snippet on how to get the first element of array in python
array = [12,34,78,90];
first_element = array[0]
This code uses a built-in function in the Python programming language to get the first element of a given array. The array is defined in line one, containing four elements: 12, 34, 78, and 90. In line two, the first element is assigned to the variable “first_element”. The function “[0]” used in line two is a specialized indexing syntax in Python that starts counting elements at 0. This means that array[0] pulls the first element in the array, which in this example is 12. As such, first_element is assigned the value 12.