Reputation: 349
Is there a more succinct way to do this?
MyList = [(1,2,3),(6,6,7)] # example
msg = "";
for (a,b,c) in MyList:
msg += str(b)
Upvotes: 0
Views: 37
Reputation: 11067
Yes, join
.
str_msg = "".join([str(b) for (a,b,c) in MyList])
Where the starting quotes contain any delimiter you might want to use between elements and where MyList
is some collection of string items.
Upvotes: 3