python tuple key dictionary
'''
Dictionaries need hashable data as key.
Lists are not hashable so you can't use them as a key.
Tuples are hashables.
A way to do is to convert list to tuple before using them as a
dictionary key
'''
python tuple key dictionary
'''
Dictionaries need hashable data as key.
Lists are not hashable so you can't use them as a key.
Tuples are hashables.
A way to do is to convert list to tuple before using them as a
dictionary key
'''
dictionary to tuple python
# Python code to convert dictionary into list of tuples
# Initialization of dictionary
dict = { 'Geeks': 10, 'for': 12, 'Geek': 31 }
# Converting into list of tuple
list = list(dict.items())
# Printing list of tuple
print(list)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us