Answers for "access list items in python"

3

access list items in python

#Negative indexing means start from the end

-1 refers to the last item, -2 refers to the second last item etc.

thislist = ["apple", "banana", "cherry"]
print(thislist[-1])

#Outputt: cherry
Posted by: Guest on March-01-2022
1

how to access items in a list

list_example = ["python","ruby","java","javascript","c#","css","html"]
print(list_example[3])#javascript
print(list_example[0])#python
print(list_example[6])#html
print(list_example[0:3])
Posted by: Guest on December-23-2021

Python Answers by Framework

Browse Popular Code Answers by Language