I'm working with collection's namedtuple to return a list of tuple from within a function as such:
def getItems(things_list) -> list:
for i, j in enumerate(things_list):
[*things_id] = things_list[i].id
[*things_title] = things_list[i].title
things_structure = namedtuple('things', ['id', 'title'])
[*things_list] = [
things_structure(things_id, things_title)
]
return things_list
if I run
callGetItems = getItems(list_of_things) # assume list_of_things is a dictionary
print(callGetItems)
it will only print the first index of the return value, as you can see I'm actually expecting the whole dictionary to be printed with their respective id and title.(assume there is at least 3 different Key-value pairs in the dictionary)
P.s. If I print within the function, it prints all the elements stored in the [*things_list] variable as expected but the same cannot be said for iterating over the return value i.e., outside of the function. please help.
to deobfuscate things assume this is the dictionary list_of_things:
list_of_things = [
{"id" : 1,
"title" : "waterbottle",
"description" : "a liquid container"},
{"id": 2,
"title": "lunchbox",
"description": "a food container"}
]
# etc...