Python lists | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
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 Antworten
+ 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