Aradhana Tripathi

Aradhana Tripathi

  • 430
  • 3.5k
  • 117.4k

Result/Output Issue in Python Interpreter!!!

Jan 10 2024 3:10 PM

Hello,

I am running below program in Python Interpreter, I am trying to know how the value of p[1] [0] is getting printed.

Per my understanding, value of p[1][0] should be 2, 3, 1 but giving output of 2.

Can someone investigate that and help me to know the answer.

Below is the code for your reference.

>>>q=[2,3]
>>>p=[1,q,4]
>>>len(p)     #print length of p
3             #output

>>>p[1]       #print p 
[2,3]         #output

>>>p[1] [0]   #print p
2             #output

 


Answers (2)