Use a list to solve the following problem: Read in 20 numbers. As each number is read, print it only if it is not a duplicate of a number already read.

What will be an ideal response?

```
# Using a list.

values = [] # create empty list

# read in a user input
for x in range( 1, 20 ):
newValue = int( raw_input( "Enter any number: " ) )

# if the number is not in list, display it, then add to list
if newValue not in values:
print newValue
values.append( newValue )
```
Enter any number: 12
12
Enter any number: 8
8
Enter any number: 10
10
Enter any number: 12
Enter any number: 17
17
Enter any number: 16
16
Enter any number: 90
90
Enter any number: 8
Enter any number: 11
11
Enter any number: 1
1
Enter any number: 2
2
Enter any number: 4
4
Enter any number: 6
6
Enter any number: 10
Enter any number: 12
Enter any number: 11
Enter any number: 90
Enter any number: 45
45
Enter any number: 77
77

Computer Science & Information Technology

You might also like to view...

What is the prefix notation for a subnet mask of 255.255.255.240?

a. /20 b. /24 c. /28 d. /29

Computer Science & Information Technology

Which company was well-known for a token ring technology?

What will be an ideal response?

Computer Science & Information Technology