Created
February 6, 2023 23:14
-
-
Save fahdi/d768eaf5c0bb9d0459490a277d17ea4a to your computer and use it in GitHub Desktop.
Python Negative Indexes
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
class_name_test =[ | |
["Jenny", 90], | |
["Alexus", 85.5], | |
["Sam", 83], | |
["Ellie", 101.5] # <---- [-1][-1] | |
# Can be done in many ways but that's not what they wanted | |
] | |
print(class_name_test) | |
# x axis and y axis | |
# Sam's 'x axis value is class_name_test[2] | |
sams_score = class_name_test[2][1] | |
print(sams_score) | |
#Since Ellie is the last one, we gotta use the -1 to denote that! | |
ellies_score = class_name_test[-1][-1] | |
print(ellies_score) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment