showing wrong answer

Back to General discussions forum

nikhilkhyalia2589     2024-02-18 19:50:21

in the question mqaximum of array i have already checked the code twice but the compiler is showing wrong answer please check it the written code is n=30 values=map(int,input().split()) lis=list(values) maxmin=[] max1=-999999 min1=999999 if len(lis)<n: for item in lis:

      if item>max1:
          max1=item

      if item<min1:
         min1=item

maxmin.append(max1) maxmin.append(min1) print(*maxmin)

zelevin     2024-02-18 21:04:57

The formatting of your code is a mess, but I can see the

n=30

line, followed by the

if len(lis)<n:

line. Are you surprized the loop doesn't run for lists longer than 30 elements?

Please login and solve 5 problems to be able to post at forum