在这里编程新手。
输入的第一行包含整数N,即个案数。 N行跟随包含数组P的每一行,其中包含案例的详细信息。
我如何进行IO操作,以便不断提示用户输入/存储N个案例?
对于伪代码(因为我不能让它工作)我认为它应该是这样的:
for however many times N:
take P as raw_input and put it somewhere like another array?
答案 0 :(得分:2)
以下是您想要的示例:
inputs = []
nums = 5 #number of times to take input
for _ in range(nums):
inputs.append(raw_input('Please enter text: '))
OR
inputs = []
nums = 5 #number of times to take input
for i in range(nums):
inputs.append(raw_input('Please enter input {}: '.format(i+1)))
#Run your script
Please enter input 1:
Please enter input 2:
Please enter input 3:
Please enter input 4:
Please enter input 5: