3/15/2023

get first item in dict (python sample code)

 refer to code:


.

my_dict = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}

# Get the first key-value pair from the dictionary
first_key, first_value = next(iter(my_dict.items()))

print("First key:", first_key)
print("First value:", first_value)

..


Thank you.

www.marearts.comπŸ™‡πŸ»‍♂️

No comments:

Post a Comment