Use of double asterisk (**) in python

Photo by James Harrison on Unsplash

Introduction :

Double asterisk (**) is used for packing/unpacking a dictionary.

Flexibility provided by ** is that we can unpack or pack dictionary of any number of key-value pair.

Unpacking dictionary :

Packing dictionary :

To sum up:

In unpacking a dictionary, we need a predefined dictionary which is used as an input in a function and we get all the items unpacked.

In packing a dictionary, we create a dictionary using arguments as keys and values of arguments as values for a newly created dictionary.

--

--

--

I am a keen learner and diligent teacher with special interest in mathematics and machine learning.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

RetryWhen advantage over Retry of Rxjs

Rxjs shareReplay to Cache HTTP Responses Observable to prevent duplicate Service calls

Tree AND Linkedlist

Setting Up an Email Form With Node.js, Express, and Mailgun Part 1

Rise of the Reducer Pattern

How to Promise

React Routing 101

Vuex and NuxtJs, get Modules Working

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gaurav Patil

Gaurav Patil

I am a keen learner and diligent teacher with special interest in mathematics and machine learning.

More from Medium

Tutorial 4: OOPs in Python — Polymorphism

Python Unknown (Tips and Tricks) — Part 1

Input and Output in Python

Python — How To Read One File Line by Line