Answers for "python iter on a (dic key) value"

0

python iter on a (dic key) value

items = d.items()
print(items)
print(type(items))
# dict_items([('key1', 1), ('key2', 2), ('key3', 3)])
# <class 'dict_items'>

i_list = list(d.items())
print(i_list)
print(type(i_list))
# [('key1', 1), ('key2', 2), ('key3', 3)]
# <class 'list'>

print(i_list[0])
print(type(i_list[0]))
# ('key1', 1)
# <class 'tuple'>
Posted by: Guest on June-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language