Reputation: 61
Is there anyway to convert
A = [((0,0,0),), ((1,1,1),), ((2,2,2),) ]
to this
B = ((0,0,0),), ((1,1,1),), ((2,2,2),)
In other words, all I want to do is remove the end brackets so that I can input B into a certain argument. I do not want any outer parentheses/brackets/quotations on B
Any help would be appreciated. Thanks
Upvotes: 0
Views: 1141
Reputation: 33101
A quick and dirty way to do it would be to do something like this:
B = A[0], A[1], A[2]
Which results in
(((0, 0, 0),), ((1, 1, 1),), ((2, 2, 2),))
Upvotes: 0
Reputation: 22902
If you are passing A
as an argument to a function fn(A1, A2, A3)
, you can pass the elements of A
individually as follows:
fn( *A )
The *
operation on a list/tuple when passed to a function unpacks the elements in the list/tuple.
Upvotes: 2
Reputation: 184280
Assuming you want a string representation:
B = ", ".join(repr(t) for t in A)
Upvotes: 0