Alchemist777
Alchemist777

Reputation: 1681

Convert list items to tuple

I have a list like this.

['February 01,2011 - February 28, 2011', 'March 01,2011 - March 31, 2011']

I want to convert it to

[('February 01,2011 - February 28, 2011'), ('March 01,2011 - March 31, 2011')]

Any Ideas?? Please help!!! Thanks in advance!!!

Upvotes: 2

Views: 3760

Answers (1)

wim
wim

Reputation: 362716

To make a tuple with 1 element, append a comma in the parentheses:

>>> my_list = ['February 01,2011 - February 28, 2011', 'March 01,2011 - March 31, 2011']
>>> [(x,) for x in my_list]
[('February 01,2011 - February 28, 2011',), ('March 01,2011 - March 31, 2011',)]

Upvotes: 13

Related Questions