Python Editor

Python | Lesson3 | Arrays

 


# Create an array of integers
integers = [1, 2, 3, 4, 5]

# Print the array
print(integers)  
# Access an element of the array
print(integers[2]) # 3

# Modify an element of the array
integers[2] = 6
print(integers)

# Append an element to the array
integers.append(7)
print(integers)
# Remove an element from the array
integers.remove(4)
print(integers)  

# Get the length of the array
print(len(integers))

No comments:

Post a Comment