AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Python Tuples


Python Tutorial » Python Tuples

Tuples are sequences, just like lists. Tuples are used to store multiple items in a single variable.
The differences between tuples and lists are, tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.

Example: Create Python List:
my_tuple = ("John", "Ann", "Chris", "Tom")
print(my_tuple)

Output:
('John', 'Ann', 'Chris', 'Tom')


Python Tuplets Allow Duplicates - examples



Example:
my_tuple = ("John", "Ann", "Chris", "Tom", "John", "Tom")
print(my_tuple)
Output:
('John', 'Ann', 'Chris', 'Tom', 'John', 'Tom')


Tuple Length


Example:
my_tuple = ("John", "Ann", "Chris", "Tom", "John", "Tom")
print(len(my_tuple))
Output:
6


Tuple Items - Data Types


Elements can be of any data type.

Example: elements can be any data type:
my_tuple1 = ("John", "Ann", "Chris", "Tom", "John", "Tom")
my_tuple2 = (9, 22, 31, 12, 87, 3)
my_tuple3 = (True, False, False)

print(my_tuple1)
print(my_tuple2)
print(my_tuple3)
Output:
('John', 'Ann', 'Chris', 'Tom', 'John', 'Tom')
(9, 22, 31, 12, 87, 3)
(True, False, False)




python tuple to list, to string, methods, vs list, append, get first, unpacking, first element, to dict, add element
Python Tuples - python

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Upload Image, display, edit and delete i...
Login Form with Image background...
How to Create an Image with Transparent ...
Portfolio Gallery Website with filtering...
Simple pagination script PHP MySQLi...
Center Image in div...
Image Hover Overlay Fade...
Sticky image / element / div on scroll...
Responsive images...
Create rounded image in HTML CSS...
Add border around image...
Position Text Over an Image HTML CSS res...
Create a Slideshow Images Gallery...
Create a Sticky Sidebar...
Search bar using CSS HTML...
Shrink Navigation Menu on Scroll...
How to Create Accordion HTML Templates...
Dropdown menu in the navigation bar...
Responsive Top Navigation Bar with mobil...
Split horizontal navigation bar...