-1
t=int(input())

for _ in range(t):
    n=int(input())
    marks=[int(x) for x in input().split()]
    min=min(marks)
    max=max(marks)
    print(min, max)

my input is

2
5
1 2 3 4 5
5
23 45 56 89 78

Ouput:

1 5
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    min=min(marks)
TypeError: 'int' object is not callable

why I am getting is error when t is greater than 1. Please, Explain the working of the of the min() and max().

1
  • 1
    You overwrote the builtin functions min and max. Voting to close as a typo. Commented Oct 26, 2019 at 14:34

1 Answer 1

0

When you call a variable max or min then the python interpreter overwrites the built in max() and min() functions so that you can use those keywords for your variable names.

You really really want to avoid doing this as it'll break stuff (like it has here) further on down the line. So call your variables something else, like:

max_mark = max(marks)
min_mark = min(marks)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.