Python lists

A list in Python is a datatype that is used to store multiple values. A list can be formed by assigning different values inside square brackets and separated by commas. Example mylist = ["India", "France", "Australia", "Nepal"] print(mylist) Output: [“India”, “France”, “Australia”, “Nepal”] Items in list are ordered, indexed, and …

Python lists Read More »

Python tuples

Like lists, tuples are also used to store multiple values in a single variable. It is a collection that is ordered and unchangeable. Unlike lists, Tuples are written with round brackets. Example sample_tuple = ("east", "west", "north", "south") print(sample_tuple) Output: (“east”, “west”, “north”, “south”) Tuples are ordered Tuples are ordered, …

Python tuples Read More »

Python sets

Just like the lists or tuples, a set in python is also one of the collection types. A set is unordered, unindexed, and unchangeable. It is written using curly braces. Example of a set: cities = {'Delhi', 'Mumbai', 'Hyderabad', 'Bhopal'} print(cities) Output: {‘Delhi’, ‘Mumbai’, ‘Hyderabad’, ‘Bhopal’} Set items are unordered …

Python sets Read More »