B.Tech Students: Apply for Live Programming Internship C, C++, Java, Python ,Web page Designing, PHP Access Tuple Items in Python | LiveCodeProgramming
Python Installation First Python Program Control Flow if...else nested if else match-case logical-operators for loops while loops break / continue Functions Defining Functions Function Arguments Function return value Lambda Function Recursion Exception Handling Exception Handling Try Except Else and Finally Raise Exception Custom Exceptions File Handling File in python Read File Write File Append File Delete File Exception Handling

Accessing Tuple Items in Python

You can access items in a tuple using indexing, slicing, or loops. Below are examples:

Tuple के items को access करने के लिए हम indexing, slicing या loop का उपयोग कर सकते हैं। नीचे उदाहरण दिए गए हैं:

1. Access by Index
students = ("Abhishek", "Chaitanya", "Naincy", "Aryan")
print(students[1])
Output:
Chaitanya
2. Negative Index
print(students[-1])
Output:
Aryan
3. Access Range (Slicing)
print(students[1:4])
Output:
('Chaitanya', 'Naincy', 'Aryan')
4. Loop Through Tuple
for name in students:
    print(name)
Output:
Chaitanya
Naincy
Aryan