From the course: Python Quick Start

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Leveraging tuples in Python

Leveraging tuples in Python - Python Tutorial

From the course: Python Quick Start

Leveraging tuples in Python

When working with collections of data, you might encounter a situation where you want to store some information in a sequence and ensure that the sequence is not changed afterwards. Say you're given a task involving a set of children's birth information. For each child, you have their first name, the hospital where they were born, their birth city, their birth state, their birth country, their date of birth, and their time of birth. You want to store the birth information of each child in a sequence. Now, say all the information you have is accurate and you correctly create a sequence containing a child's birth information. Most likely, you will not need to change that sequence later. In fact, you do not want that sequence to be tampered with or altered. So you need to use a sequence that cannot be changed after creation. Don't worry, Python has a type of sequence that helps you do this easily. And it's called a tuple. A tuple has a specific order and the items in a tuple cannot be…

Contents