How do I remove the square parenthesis from each element from the list For example if I have list = [['a'],['b'],['c'],['d'] how can I get an output ['a','b','c','d']
Asked
Active
Viewed 36 times
1 Answers
0
You can try using a for loop. Code:
l = [['a'], ['b'], ['c'], ['d']]
new_l = []
for elem in l:
new_l.append(elem[0])
Abhigyan Jaiswal
- 2,217
- 2
- 7
- 26
-
FWIW, `new_l = [e[0] for e in l]` would suffice too… – deceze Jan 05 '21 at 12:13