I was looking for how to create nested list from dictionary. Here is the given Dictionary.
Dict={'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'], 'Kenneth Love': ['Python Basics', 'Python Collections'],'Jason Bourne':['black berry','mango','potato','oli','key'],'fruits':['cherry','pineapple','banana','coconut']}
Excepted output:
[['Jason Bourne', 5], ['Kenneth Love', 2], ['fruits', 4], ['Jason Seifer', 3]]
Here order doesn't matter
简单的理解:
result = [[k, len(v)] for k,v in Dict.items()]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.