find the first element in an array in python

To find the first element in an array in python, you can use indexing. In Python, indexing starts at 0, so the first element of an array can be found using index 0. Here's an example:

main.py
my_array = [1, 2, 3, 4, 5]
first_element = my_array[0]
print(first_element)
76 chars
4 lines

Output:

main.py
1
2 chars
2 lines

In this example, we created an array my_array and assigned it a list of numbers. We then used indexing to find the first element of the array and assigned it to first_element. Finally, we printed the value of first_element, which is 1.

gistlibby LogSnag