-2

in my Python program I work with lists, my list looks like this: List1=[[X1, X2, X3], [Y1, Y2, Y3]] I only want to display the value X1 from this list with Print.

I tried the following: print(List1[0]) but X1,X2,X3 is displayed. I only need the X1 displayed.

thanks for your help in advance

Othman
  • 1
  • 2

1 Answers1

1
print(List1[0][0])

List1[0] is displaying the first value of your list, which happen to also be a list

List1=[[X1, X2, X3], [Y1, Y2, Y3]] so List1[0] = [X1, X2, X3]

List1[0][0] means displaying the first value of the first value of your List1, ence in your case X1