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.py76 chars4 lines
Output:
main.py2 chars2 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