In python write a program that reads numbers and adds them to a list if they aren't already contained in the list. When the list contains ten numbers, the program displays the content and quits.

Respuesta :

The program that reads numbers and adds them to a list if they aren't already contained in the list is as follows;

aList = []

while len(aList) != 10:

    n = int(input("Enter the value: "))

    if not n in aList:

         aList.append(n)

print(aList)

Code explanation;

The code is written in python.

  • We declared a variable "aList" with an empty list .
  • We used the while loop to make sure the loop continue if the length of the aList list is equals to 10.
  • Then we input our number continuously until the list is up to ten.
  • If our input is not in the list , it will append it to our declared "aList".
  • Finally, we print out the aList.

learn more on python here: https://brainly.com/question/27075682

Ver imagen vintechnology
Ver imagen vintechnology