How to convert list into 2 tuple pair list

0 votes

How to convert the list into 2 tuple pair lists?

I'll give an example:

L = [1,1,2,2,1,2]

/ i want the above list to 

L2 = [(1,1) , (2,2) ,(1,2)]
Nov 4, 2020 in Python by anonymous
• 8,910 points
5,885 views

1 answer to this question.

0 votes

This should work:

L = [1, 2, 3, 4, 5, 6]
L2 = []

for i in range(0, len(L), 2):
 L2.append((L[i], L[i+1]))

print(L2)
answered Nov 4, 2020 by Gitika
• 65,910 points

Related Questions In Python

0 votes
1 answer

How to have values from a List1 into Columns Names and List 2 Values as Index for an Empty DataFrame

Try like this, it will give you ...READ MORE

answered Jul 10, 2019 in Python by Cherukuri
• 33,030 points
767 views
0 votes
1 answer

How to convert each list item into string in a column of data frame. ?

Hey, To split a string you can use ...READ MORE

answered Feb 5, 2020 in Python by Roshni
• 10,520 points
694 views
0 votes
1 answer

How to convert one list into generator?

Hi@akhtar, Say, you have one list A. Now convert ...READ MORE

answered Apr 23, 2020 in Python by MD
• 95,440 points
1,961 views
0 votes
1 answer

How to convert a dataframe into list?

Hi@akhtar, You can convert your dataframe into list. ...READ MORE

answered Apr 25, 2020 in Python by MD
• 95,440 points
459 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,061 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,480 views
0 votes
1 answer

How to transform a Python string into a list?

Hi, @Roshni, You can use Python <split()> function ...READ MORE

answered Jun 26, 2020 in Python by Gitika
• 65,910 points
413 views
0 votes
1 answer

How to convert doc file into pdf using python?

A simple example using com types, converting ...READ MORE

answered Nov 4, 2020 in Python by Gitika
• 65,910 points
1,672 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP