[Tutor] How to give input to a list

surya kasturi suryak at live.com
Sun Oct 2 05:20:01 CEST 2011


Hi,

How give input to a list all at once. 
I mean if we declared a array and like to take input for it

for (i=0;i<5;i++)
     scanf("%d",&array[i]);
here we can give input of 5 numbers with a space in command prompt. 

Similarly in python if i create a list and do similar process 

list = [ [ ], [ ] ]
for i in range (0,2):
        for j in range (0, 2):
                 list[i].append ( int (raw_input()) )

here, I am expecting a list like
[ [1,2] , [3,4] ] 

but when I give 1,2,3,4 with space in command prompt at once, it shows error.

How do i overcome this problem? 
        
Actually my problem goes to sudoku solver where i need to take input all at once. What should i do ? 



More information about the Tutor mailing list