0

When given an input:

3
2 1
1 1 0

How would I take that input and store it as a list like so:

examList = [
      [3],
      [2,1],
      [1,1,0]
]

How do you identify the end user input if there any no specific indicators?

Currently have the following code:

examList = []
i = input()

while i != '':
    examList.append([int(s) for s in i.split()])
    i = input()

But I keep getting EOF errors when reading the last elements into the list.

William Merritt
  • 429
  • 1
  • 5
  • 12
  • Move `print` statement outside of while loop. I've executed this code and didn't face any such error. – Mushif Ali Nawaz Feb 25 '18 at 19:34
  • Check if your IDE supports input() function.Check this one https://stackoverflow.com/questions/12547683/python-3-eof-when-reading-a-line-sublime-text-2-is-angry – Alex Delarge Feb 25 '18 at 19:39

1 Answers1

1
examList = []
i = input()

while i != "":
    examList.append(list(map(int,i.split())))
    i = input()

print(examList)

it can be done in this way.

arundeepak
  • 564
  • 2
  • 12