Exercise 74

Write a Python algorithm that asks the user to enter successively 7 integers and display the list of numbers entered by ignoring repeated numbers. Example if the user enters the numbers: 2, 11, 3, 2, 3, 5, 2. the algorithm returns the list

[2, 11, 3, 5]

Solution

#Initialization of the list of entered numbers
listNumbers = []
for i in range (0, 7):
n = int (input ("Enter a number"))
if n not in listNumbers:
listNumbers.append (n)
print ("The list of numbers entered on the keyboard is:", listNumbers)
Younes Derfoufi
my-courses.net

Leave a Reply