How to Join Keys From Dictionary in Python
Posted on: February 27, 2021 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.
Share on social media
//