

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Accessing Values of Lists in Python
To access values in lists, use the square brackets for slicing along with the index or indices to obtain value available at that index.
Example
#!/usr/bin/python list1 = ['physics', 'chemistry', 1997, 2000]; list2 = [1, 2, 3, 4, 5, 6, 7 ]; print "list1[0]: ", list1[0] print "list2[1:5]: ", list2[1:5]
Output
When the above code is executed, it produces the following result −
list1[0]: physics list2[1:5]: [2, 3, 4, 5]
- Related Questions & Answers
- Accessing Values of Strings in Python
- Accessing Values of Tuples in Python
- Accessing Values of Dictionary in Python
- Safely Accessing Deeply Nested Values In JavaScript
- Unpacking tuple of lists in Python
- Python - Intersection of multiple lists
- Accessing Attributes and Methods in Python
- Python program to find missing and additional values in two lists?
- Intersection of Two Linked Lists in Python
- Updating Lists in Python
- Accessing all elements at given Python list of indexes
- Accessing Key-value in a Python Dictionary
- Custom Multiplication in list of lists in Python
- How to join list of lists in python?
- All possible permutations of N lists in Python
Advertisements