+ 1

I need this code I wrote to be further processed to give the exact value for of the result based on the comments

# a function to flatten a list. #The list contains other lists, #strings, or ints. e.g example, #[[1,'a',['cat'],2],[[[3]],'dog'],4,5] #is flattened into #[1,'a','cat',2,3,'dog',4,5] (order #matters). def flatten(aList): ''' aList: a list Returns a copy of aList, which is a flattened version ''' r=[] k=[] for item in aList: if type(item) is list: r.extend(flatten(item)) else: k.append(item) if k: r.insert(0,k) return r

2nd Apr 2017, 12:00 AM
Samuel Akosa
Samuel Akosa - avatar
2 odpowiedzi
+ 1
I love you
18th Jul 2017, 10:51 PM
Cody
0
Thank you
20th Jul 2017, 3:17 PM
Samuel Akosa
Samuel Akosa - avatar