• Flatten a List on O'Reilly


I would like to give some feedback about https://py.checkio.org/mission/flatten-list/legacy-solve/ ... it appears the system only starts new and fresh locally inside the defined function. The variable I've assigned outside the function maintains its value from the last assertion test.

I tried to rectify this issue by making the variable global, but to no avail. The solution works in an IDE, obviously, in my case, I'm using PyCharm. Is this not a valid or acceptable way to complete this particular challenge? The code I used is as follows:

nums = []

def flat_list(array):
    for item in array:
        if type(item) is list:
        elif type(item) is int:
    return nums

I've included some screenshots showing the different output from my end. The function name and variable names have been changed to protect the innocent :P


Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36