Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python negative indexing

list = ["Python", "Java", "C++", "Javascript", "SQL", "PHP"]
print(list[-1]) # "PHP"
print(list[-4]) # "C++"
print(list[:-3]) # ["Python", "Java", "C++"]
print(list[-2:]) # ["Javascript", "SQL", "PHP"]
print(list[-5:-2]) # ["Java", "C++", "Javascript"]
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #python #negative #indexing
ADD COMMENT
Topic
Name
1+8 =