Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python list input error

grid = []
for _ in range(3):
    grid.append(raw_input().split())

Input:

000
000
000

Output: [['000'], ['000'], ['000']].

How do I change my code to get the output?

[['0','0','0'], ['0','0','0'],['0','0','0']]

like image 936
John Constantine Avatar asked Dec 10 '22 23:12

John Constantine


1 Answers

You have:

"000".split() == ["000"]

You want:

list("000") == ["0", "0", "0"]
like image 188
Bill Lynch Avatar answered Jan 06 '23 06:01

Bill Lynch