{"id":347,"date":"2022-07-22T00:00:00","date_gmt":"2022-07-22T00:00:00","guid":{"rendered":"https:\/\/tac.debuzzify.com\/?p=347"},"modified":"2023-06-20T08:39:21","modified_gmt":"2023-06-20T08:39:21","slug":"python-tuples-to-lists-sets-dictionaries","status":"publish","type":"post","link":"https:\/\/www.the-analytics.club\/python-tuples-to-lists-sets-dictionaries\/","title":{"rendered":"Converting Tuples to Lists, Sets, and Dictionaries in Python."},"content":{"rendered":"\n

Tuples<\/a> are one of the four types of collections in Python. Lists, Sets, and Dictionaries are the other three.<\/p>\n\n\n\n

Tuples have a slight advantage over lists when it comes to performance. But at the expense of some flexibility. Unlike lists, tuples don’t allow modifications.<\/p>\n\n\n\n

Sets are another similar collection type to tuples. Yet, sets don’t allow duplicates, and they are not ordered. In contrast, lists and tuples are ordered<\/a> and allow repeated elements. Thus, sets are not indexed, and they don’t support slicing operations as lists and tuples do.<\/p>\n\n\n\n

Dictionaries are a type of key-value mapping in Python. Starting from Python 3.7, elements in a dictionary (key-value pairs) are ordered. You can modify dictionaries (mutable), Add or remove new items to them, or can nest them with other dictionaries.<\/p>\n\n\n\n

For the many benefits of each collection type, you may want to jump from one type to the other frequently.<\/p>\n\n\n\n

This post is all about how to convert tuples to other collection types.<\/p>\n\n\n\n\n\n

Tuples to Lists<\/h2>\n\n\n\n

Lists and tuples are the most alike among all the collection types. Hence, you’d frequently encounter switching between them.<\/p>\n\n\n\n

Also, these conversions are fairly easy in Python.<\/p>\n\n\n\n

Converting a tuple to a list.<\/h3>\n\n\n\n