Home » 2021 » November

How to Merge Dictionaries in Python, With Examples

Python Merge Dictionaries

This article will show you the simplest ways to merge two or more dictionaries in the Python programming language. Note that the code examples in this article are written for Python version 3 – and will not work with Python version 2! What is a Dictionary in Python? We’ve covered what dictionaries are in our article here. As there are a couple of ways to merge multiple dictionaries in Python, we’ve put together this article separately to make sure we’ve got everything covered! Merging/Joining Using Dictionary Union … Read more

Home » 2021 » November

The Python ord() Function – What it Does and How to Use It

Python ord()

The ord() function returns an integer representation of a Unicode character. Here’s why it does that and how it’s used. Python ord() Function Syntax First, here’s the syntax for the ord() function: ord(CHAR) Note that: CHAR is the single Unicode character you wish to receive the corresponding integer representation of Only a single character is allowed! OK, But Why? The integer returned by ord() is the Unicode code point of the character. It’s a unique number that identifies the character. Unicode represents characters from several languages and includes symbols, emojis, and combinations of all of them. When data is saved … Read more

Home » 2021 » November

How to Slice a Dictionary in Python, With Examples

Python Dictionary slice()

We’ve covered how to use the slice function to slice strings, tuples, lists, and other sequences. This tutorial will show you how to slice dictionaries, with examples. Dictionaries Not sure what a dictionary is in the Python programming language? Get up to speed with our article here. The slice() Function and the islice() Function Check out the full article here on how the slice() function works – we’ve covered it in-depth. Unfortunately, the slice() function built-in to Python does not work with dictionaries. If you do try to use slice() with a dictionary type variable, you will receive the following error: TypeError: … Read more