+ 2

How can I change tuples in a list to just a list?

How can I change [(2,3),(4,5)] to [2,3,4,5]?

1st Feb 2019, 9:39 PM
Leo Hunter
Leo Hunter - avatar
4 Answers
+ 5
a = [(2, 3), (4, 5)] b = list(a[0]) + list(a[1]) or in a more generic way: b = [ ] for i in range(len(a)): b += list(a[i])
1st Feb 2019, 10:06 PM
Pedro Tortello
Pedro Tortello - avatar
+ 2
https://code.sololearn.com/c2GN3in0c8sm/?ref=app
2nd Feb 2019, 3:24 AM
Dan Rhamba
Dan Rhamba - avatar
+ 1
Thank you
1st Feb 2019, 10:06 PM
Leo Hunter
Leo Hunter - avatar