I am new to Python and want to read keyboard input into an array. The python doc does not describe arrays well. Also I think I have some hiccups with the for loop in Python.
I am giving the C code snippet which I want in python:
C code:
int i;
printf("Enter how many elements you want: ");
scanf("%d", &n);
printf("Enter the numbers in the array: ");
for (i = 0; i < n; i++)
scanf("%d", &arr[i]);
raw_input is your helper here. From documentation –
So your code will basically look like this.
P.S: I have typed all this free hand. Syntax might be wrong but the methodology is correct. Also one thing to note is that,
raw_inputdoes not do any type checking, so you need to be careful…