Lily C.

asked • 01/14/21

Python Lists (User Input with all integers)

Hello! I designed this code that takes in user input and creates a list and then outputs the sum, highest number, lowest number, and average. Right now it can only take in whole numbers but I was wondering how I could change it so it could take in decimal numbers(i.e: 1.5) and fractions (i.e: 1/2) as well. Thanks!

list = []

integer = int(input("Hello please enter an integer between 3 and 20: "))

if integer >= 3 and integer <=20:

for i in range(integer):

number = int(input("Enter that number of integers: "))


print("Integers are: " , list)

print("Sum of all elements in given list: " , sum(list))

print("Highest number: " , max(list))

print("Lowest number: " , min(list))

avg = int(sum(list) / number)

print("Average of all the numbers is: " , avg)

print("Thank you for running this code!")


print("Sorry that is not a good number!")

Patrick B.

And if the user inputs zero denominator????


1 Expert Answer


Patrick B. answered • 01/14/21

4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.