-2

Now I want to run multiple test cases one by one and display the output together line by line.

n=input()
for i in range (0,int(n)):
   #takes input and runs the code
   #stores output in a string
#prints output for all n cases one by one

How can I make the program to store N outputs of N different test cases in N different strings without actually defining N strings myself??

  • You might want to consider creating a reproducible example. For inspiration (even though you do not ask about pandas): https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples/38466059 Alternatively, draw an inspiration from the world of R programming language: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – ira Sep 03 '18 at 14:26

1 Answers1

0

You can store them in a list. As an example:

n=input()
testResults = []
for i in range (0,int(n)):
  inp = input()
  output = runCase(inp)
  testResults.append(str(output))
for result in testResults:
   print(results)

Str converts output to string and append adds it to the end of the list.

Additionaly, your question is not a good one. I suggest taking a look at here: https://stackoverflow.com/help/how-to-ask

dgkr
  • 345
  • 2
  • 8
  • "How to ask" is a good read for everyone and the question could be improved (I did it) but in general it's a good, sufficiently clear question, otherwise you couldn't have devised the correct answer, could you? – gboffi Sep 03 '18 at 14:17