mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Fixed erroneous output and added a little clarity on the matter
list.index(argument) would return the index of the item in the list that first matched the argument It will not return the value stored at the index of the argument as it was prior. Added some more clarity to the subject as well.
This commit is contained in:
parent
30e364f410
commit
3c4a2ff91c
@ -224,8 +224,8 @@ li.remove(2) # Raises a ValueError as 2 is not in the list
|
||||
# Insert an element at a specific index
|
||||
li.insert(1, 2) # li is now [1, 2, 3] again
|
||||
|
||||
# Get the index of the first item found
|
||||
li.index(2) # => 3
|
||||
# Get the index of the first item found matching the argument
|
||||
li.index(2) # => 1
|
||||
li.index(4) # Raises a ValueError as 4 is not in the list
|
||||
|
||||
# You can add lists
|
||||
|
Loading…
Reference in New Issue
Block a user