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

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.


HTML Image tag, code...
How to code in HTML...
HTML text tag...
HTML text, how to display...
Container responsive styles...
HTML container tag...
HTML container...
Send forgot password by mail or message ...
PHP MySQL simple login system...
Check for duplicate username live or ema...
How to create simple search engine using...
Diseño de sitio web CSS Layout...
Diseño de caja flexible CSS3...
Botones en CSS...
ID y Clase, Diferencias entre Class e Id...
Esquina redondeada CSS...
Tamaño de caja css box-sizing: border-b...
Alineación CSS...
Altura y Anchura CSS...
Bordes CSS...