简体   繁体   中英

how to assign function output to variable

im trying to get the list that is outputted by the function and assign the list to a variable so i can use the len method on it but I don't know how

def count(list):
return ([i for item in list for i in item.split()])

list = [""]

Does this answer your question?

def count(item_list):
    return ([i for item in item_list for i in item.split()])

list_returned_by_count = count(item_list)

Then, you can use the len method on it.

len(list_returned_by_count)

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