Skip to content

> Script Everything

  • Spreadsheets
  • Python
  • About

dictionaries

Create A Dictionary In Python: Quick 5 Minute Beginners Guide

March 16, 2023 January 28, 2023 by Ryan Sheehy

How do you create a dictionary in Python? Dictionaries in Python are mutable data types that contain key: value pairs. A dictionary can be a great way to organise information, especially if checks need to be performed prior for uniqueness and/or the value of that key needs to be changed, skipped or inserted. Creating A …

Read more

Categories dictionaries , Python

What Does Asterisk Before Variable Mean In Python?

March 12, 2022 by Ryan Sheehy

What does the asterisk before a variable name mean in Python? For example, if I have a variable that contains a list of strings and the name of the variable is called my_list what does *my_list do? The asterisk is an operator in Python that is commonly known as the multiplication symbol when used between …

Read more

Categories dictionaries , lists , strings , tuples

Python Initialize Dictionary: Use Dict Constructor Or Dict Literal?

March 16, 2023 March 10, 2022 by Ryan Sheehy

How do you initialize an empty dictionary in Python? Is it best to use dict() or {}? There are two common ways of initializing a dictionary in Python. One involves using the built-in function dict() and is known as the dict constructor, whereas the other method is known as dict literal and has the syntax …

Read more

Categories Coding , dictionaries , Python

Sort Dict By Value Or Sort Dict By Key In Python: 1 Liners

November 12, 2021 by Ryan Sheehy

It can be easy to sort a list, whether a list of strings or even a list of dictionaries, but can you sort a dictionary? One way to sort a dictionary by the values of each key : value pair in Python is to use a dictionary comprehension. Dictionary comprehensions are very similar to list …

Read more

Categories Coding , dictionaries , Python

Enumerate Dictionary In Python: Video Demonstration

November 9, 2021 by Ryan Sheehy

Previously I looked at how to use the enumerate() built-in function with a for loop to provide two variables when iterating through a list. In that article the enumerate() function provides both an index number and the element in each list by wrapping these together into a tuple. But what happens when the enumerate() function …

Read more

Categories Coding , dictionaries , Python
YouTube Twitter
  • Send A Message
  • Privacy Policy
© 2023 > Script Everything • Built with GeneratePress