FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Python Tuples Explained Simply (Immutable Sequences)
How-ToMachine Learning

Python Tuples Explained Simply (Immutable Sequences)

via Dev.to TutorialShahrouz Nikseresht8h ago

Tuples are ordered collections similar to lists, but they cannot be changed after creation. This makes them useful for data that should stay fixed. What is a tuple? A tuple is created with parentheses () and items separated by commas. coordinates = ( 10 , 20 ) colors = ( " red " , " green " , " blue " ) single_item = ( 5 ,) # Note the comma for one item You can also create a tuple without parentheses: point = 3 , 4 An empty tuple: empty_tuple = () Tuples can contain mixed types and are immutable. Accessing elements Use indexes just like lists (starting at 0). colors = ( " red " , " green " , " blue " ) print ( colors [ 0 ]) # red print ( colors [ - 1 ]) # blue Slicing works too: print ( colors [ 1 : 3 ]) # ("green", "blue") Why use tuples instead of lists? Tuples are immutable: you cannot add, remove, or change items. This protects data from accidental changes. Tuples are faster than lists. Tuples can be used as dictionary keys (lists cannot). Attempting to modify raises an error: colo

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
2 views

Related Articles

How-To

How to Install and Start Using LineageOS on your Phone

Lobsters • 56m ago

How-To

What Should Kids Learn After Scratch? Comparing Programming Languages

Medium Programming • 4h ago

BYD rolls out EV batteries with 5-minute ‘flash charging.’ But there’s a catch.
How-To

BYD rolls out EV batteries with 5-minute ‘flash charging.’ But there’s a catch.

TechCrunch • 4h ago

Trump gets data center companies to pledge to pay for power generation
How-To

Trump gets data center companies to pledge to pay for power generation

Ars Technica • 6h ago

Building an Interactive Fiction Format with Codex as a Development Partner
How-To

Building an Interactive Fiction Format with Codex as a Development Partner

Medium Programming • 8h ago

Discover More Articles