I am trying to write a function that uses a while loop. The program must find the average, maximum and minimum of the numbers that the user inputs. Then I need to call the function from another module. I have managed to get the average to work, but I cannot use the max() and min() functions correctly it seems.

The error message I get is:

Traceback (most recent call last):

File "C:\Users\Scott\workspace\woooo\herro.py", line 6, in <module>

total, average, smallest = maggiespizza.sla(n)

File "C:\Users\Scott\workspace\woooo\maggiespizza.py", line 15, in sla

smallest = min (x)

TypeError: 'int' object is not iterable

Here is my code:

- Code: Select all
`def sla (n):`

FIRST_N = n

total = 0

while n > 0:

x = int(input("Enter a value: "))

total += x

n = n - 1

average = total / FIRST_N

smallest = min (x)

return total, average, smallest