[SOLVED] Eof error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[SOLVED] Eof error

I am trying to input a matrix of arbitrary length(in my case: 1 2 \n 3 4) and receive "EOFError: EOF when reading a line". What's wrong? matrix = [] while True: s = input() if not s: break matrix.append(s) print(matrix)

12th Aug 2020, 3:41 PM
[][]
3 Answers
+ 2
matrix = [] while True: try: s = input() except : break matrix.append(s) print(matrix) At last, You need to press empty enter at least to your program work without error.. And this is alternative.. It works as you expecting....
12th Aug 2020, 3:56 PM
Jayakrishna 🇮🇳
+ 3
You need to provide all the inputs on sololearn at once since it's not interactive
12th Aug 2020, 3:51 PM
Abhay
Abhay - avatar
+ 1
Thank you!
12th Aug 2020, 4:13 PM
[][]