Python Forum
How to print data in bracket in list in one side. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to print data in bracket in list in one side. (/thread-19976.html)



How to print data in bracket in list in one side. - phob0s - Jul-22-2019

I have to print a list partially, data inside bracket, but in a right side, here is the code:

...
print("mdx:",mdx)

    mdx.sort()

    for indice in range(lg):
            print(mdx[indice])
Résult :

mdx: [(1, 0), (4, 1), (0, 2), (3, 3), (2, 4)]

(0, 2)
(1, 0)
(2, 4)
(3, 3)
(4, 1)


I need to display only the second data in the parentheses, like this:

2
0
4
3
1


Thanks for any help. Big Grin


RE: How to print data in bracket in list in one side. - sonia - Jul-22-2019

Try something like this:
for i in mdx:
  print(i[1])



RE: How to print data in bracket in list in one side. - phob0s - Jul-23-2019

Thank you Sonia ! The problem is solved.