Created
June 10, 2020 18:18
-
-
Save iJKTen/2e47a31f7b2a616a245418484975fae4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [] | |
arr.append(1) | |
arr.append(2) | |
arr.insert(2, 3) | |
arr.insert(3, 4) | |
# Add elements with a for loop | |
for index in range(4): | |
arr.append(index + 5) | |
# Our list now has 8 elements [1, 2, 3, 4, 5, 6, 7, 8] | |
arr[0] | |
arr[1] | |
# Output the length of the list | |
len(arr) | |
# Get the last element in the list | |
arr[len(arr) - 1] | |
for item in arr: | |
print(item) | |
# using enumerator | |
for index, item in enumerate(arr): | |
print(arr[index]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment