This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
In this article, you will learn how to join keys from a dictionary in Python.
Let’s say you have a dictionary of users.
user = {"Adam" : 20, "Bryan" : 18, "Cleo" : 23}
Join Keys From Dictionary in Python
In order to join keys from a dictionary, you can use the join()
method.
user = {"Adam" : 20, "Bryan" : 18, "Cleo" : 23}
# A string variable with value " " as separator
separator = " "
# Display joined keys from dictionary
print(separator.join(user))
# Adam Bryan Cleo
Note: The join()
method functions by creating a string from a supplied iterable.
The post How to Join Keys From Dictionary in Python appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
Ariessa Norramli | Sciencx (2021-02-27T10:01:10+00:00) How to Join Keys From Dictionary in Python. Retrieved from https://www.scien.cx/2021/02/27/how-to-join-keys-from-dictionary-in-python/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.