简体   繁体   中英

Append multiple items into list of lists in Python

I am trying to append items into lists of list but instead i am getting an equivalent of extend().

doc = __doc__
result = []

collector = FilteredWorksetCollector(doc)
user_worksets = collector.OfKind(WorksetKind.UserWorkset)
for i in user_worksets:
    result.append(i.Name)
    result.append(i.Kind)
OUT = result

I would like to get a list that looks like this: [[name, name, name],[kind, kind, kind]]

thank you,

OUT = [[i.Name for i in user_worksets], [i.Kind for i in user_worksets]]

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM