0
How to take a definite number of inputs from a initial input in python?
Suppose first input is a number N, then how to take N more inputs? My question is how to set number of inputs from a given integer Input.
5 Answers
+ 2
Assuming you're using Python:
N = int(input())
for _ in range(N):
next_input = input()
# do something...
+ 2
Russ thank you sir
+ 1
times = int(input())
# mabey set up an empty container
for time in times:
whatever = input()
# do something w/ input, mabey append to container
+ 1
Lothar Russ Slick thank you everyone. I got it. But Now I am facing another problem.
N = int(input())
For i in range(N):
p,q = int(input()),int(input())
print( p + q )
I don't know why but I'm getting only one output that is the last input of p,q. But I want to get output for every p,q.Sorry I didn't know I'll face this this problem and now taking your precious time otherwise I'd have mentioned it in the question. Can anyone please help me out?
+ 1
Indent your print statement so that you print the sum for every iteration, not just once after the for loop has finished.