Horje
take first n row of dictionary python Code Example
take first n row of dictionary python
a_dictionary = {"name" : "John", "age" : 35, "height" : 65}

dict_items = a_dictionary.items()

first_two = list(dict_items)[:2]
print(first_two)

OUTPUT
[('name', 'John'), ('age', 35)]

first_three = list(dict_items)[:3]
print(first_three)

OUTPUT
[('name', 'John'), ('age', 35), ('height', 65)]




Python

Related
python sort list by rule Code Example python sort list by rule Code Example
python print \n every n loops Code Example python print \n every n loops Code Example
mount gdrive in pyton Code Example mount gdrive in pyton Code Example
how to find out the max and min date on the basis of property id in pandas Code Example how to find out the max and min date on the basis of property id in pandas Code Example
python sys environment Code Example python sys environment Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8