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 3, 2020 in Python by anonymous
• 8,880 points
51 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 3, 2020 by Gitika
• 65,870 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
• 32,910 points
277 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,420 points
214 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,060 points
399 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 24, 2020 in Python by MD
• 95,060 points
104 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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,847 views
0 votes
0 answers
+4 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,810 points
1,421 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,870 points
82 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,870 points
69 views