.format_map()
Published Oct 19, 2023
Contribute to Docs
The .format_map()
string method takes a single parameter which is the input dictionary and returns the key’s values.
Syntax
string.format_map(d)
d
is the dictionary to be addressed.
Example
The example below uses .format_map()
to return the values stored in x
and y
:
# Input stored in variable a.a = {'x':'Mike', 'y':'Perry'}# Use of format_map() functionprint("That DJ is {x} {y}".format_map(a))
The output will look like this:
That DJ is Mike Perry
Codebyte Example
The following code is runnable and demonstrates the use of .format_map()
:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.