0

Python lists

b=[(1,12),(2,14),(3,11),(4,18)] I want to write a code that gives me the second number in every columns: 12 , 14, 11, 18 I tried this code but I didn’t get my desired answer: b[0:][1] I will be grateful if someone helps me

4th May 2021, 2:44 PM
Mah~
Mah~ - avatar
3 Answers
+ 3
b = [i[1] for i in b]
4th May 2021, 2:51 PM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
0
Thanks!
4th May 2021, 2:56 PM
Mah~
Mah~ - avatar
0
If you want your output in the form of list, z=[b[i][1] for i in range(len(b))] print(z)
4th May 2021, 4:31 PM
Rahul Saxena
Rahul Saxena - avatar