If I store readlines() in a variable (the readlines list has more than one element), and indexing the variable, nothing goes wrong, i.e. say if my input made up of two rows,
import sys
data = sys.stdin.readlines()
data1 = data[0]
data2 = data[1]
this will be fine.
However, if I index the readlines directly, I will get index out of range error, i.e. with the same input,
import sys
data1 = sys.stdin.readlines()[0]
data2 = sys.stdin.readlines()[1]
gives index out of range error. Why does this happen?
I attached two images below to illustrate what I am trying to point out: