Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Riseâ„¢.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
October 11, 2023
Using list comprehension It’s very easy to convert a two dimensional list into a flat (single dimensional) list.
flat_list = [num for childlist in lists for num in childlist]
Limitations:
Solution:
L = [ [1,2,3], [ [4,5,6], [7,8,9], [ [10,11,12], [13,14,15] ] ], 16,17,18 ] def flat_my_list(L: list): result = [] for element in in L: try: iter(element) result.extend(flat_my_list(element)) except: result.append(element) return result flat_my_list(L)
All of those criteria will be fulfilled by the function flat_my_list.