Learning Python Tuples: Ordered Immutable Collection

🚀 Learning Python | Topic: Tuples While learning Python, I explored Tuples — a simple yet powerful data structure. 🔹 What is a Tuple? A tuple is an ordered and immutable collection of elements. t = (1, 2, 3) 🔹 Key Points: ✔️ Ordered ✔️ Allows duplicates ✔️ Immutable (cannot be changed) ✔️ Faster than lists 🔹 Access & Slice t = (10, 20, 30, 40) print(t[1]) # 20 print(t[1:3]) # (20, 30) 🔹 Common Methods count() index() 📌 Building a strong Python foundation step by step. #Python #LearningPython #DataStructures #Beginner #AI #ML

  • text

You can use -1 traverse elements from the back (right side). print( tup[-1] ) : " -1 → last element"

Like
Reply

To view or add a comment, sign in

Explore content categories