Help me in solving KNGATK problem

My issue

My code

a = []
n = int(input("Total test case: "))
for i in range(n):
    days = int(input("Total days: "))
    temperature = [int(i) for i in input().strip().split()]
    cold = temperature[1]

Problem Link: CodeChef: Practical coding for everyone

There are a few problems with your code. First, never output anything that isn’t specified by the problem otherwise it will be marked wrong. In this case, passing an argument to the input function on lines 2 and 4 will output said string. Remove those arguments. Second, n denotes the number of test-cases. Each test-case has its own set of data and therefore its own output. You are only printing once, which means instead of say 3 outputs for 3 test-cases, you only have one. There are two ways to fix your code (assuming you addressed the first issue). You could:

  1. Iterate over a and output each element e.x.:
// your code above
for i in a:

The problem is that print(a) will print the entire array. That means your output would look something like: [answer_1, answer_2, anwer_3, ..., answer_n] (where answer_i is the i-th test-cases answer) and will not look like what is required:


The code above aims to solve this.

  1. Remove print(a) and a.append(cold), and instead, print(cold) inside the for loop right after you set cold = temperature[1]. This makes a useless and also allows you to output the answer right after computation (instead of waiting till the end and then printing all the elements of a)

Other than that, your algorithm looks right.