Can any one tell me that how i can take multiple inputs in same line in python and also by using only one variable as we do in cpp by the combination of loop and array.
For ex 2 3 5 8 9
But all using only one variable
This method is faster than loops,
we store the numbers in a list name arr
arr = list(map(int,input().split()))
where list() is used explicitly to convert to list.
map() function is used perform data type conversion for input.
input() to input the string
split() to split the input at a space as a separate value, you can change its argument for different types of split like \t,\n etc.
But in this u need to assign a variable to store new value n
No, just write arr.append(n) , its just a normal list
I am not getting it i use p=list(map(int,input().split()))
Now what to modify
can you again clarify what you wanted to do exactly, i am not getting what you are trying to say.
I have been provided a test case
First line will contain 2 numbers say a and b
And in the sec line of each test case i need to take input equal to a number of times and all need to be in same line
just find a practice problem with such input format and check python solutions.
there can be different ways…use the one u like