At Westonci.ca, we connect you with the answers you need, thanks to our active and informed community. Get detailed and precise answers to your questions from a dedicated community of experts on our Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

It requires input from a user to populate a list with three values and it's coming up wrong every time. Some values are correct and others are incorrect like [7,15,3] when called in by user it's wrong and selects 15.The goal is to display the minimum


input output right facing arrow * ##

#my_list = [7,17,10]

my_lista = [ ]


n = input( )

my_lista.append(n)

# second Value in list


n1 = input()

my_lista.append(n1)


# third value in list

n2 = input()

my_lista.append(n2)


min_num = min(my_lista)


print(min_num)

Sagot :

Answer:

I'm pretty sure the problem is that you're prompting the user to input a string value instead of an int value. This can be done by putting int() before input()

To clean it up your way, try doing:

my_lista = []

n = int(input())

my_lista.append(n)

n1 = int(input())

my_lista.append(n1)

n2 = int(input())

my_lista.append(n2)

min_num = min(my_lista)

print(min_num)

If you want to shorten the code, you can also do it this way which gives you the same output:

my_list = []

for i in range(3):

    n = int(input())

    my_list.append(n)

print(min(my_list))