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
You might also like to view...
Untying an input stream, inputStream, from an output stream, outputStream, is done with the function call:
a. inputStream.untie(). b. inputStream.untie(&outputStream). c. inputStream.tie(). d. inputStream.tie(0).
Being efficient means doing tasks ____.
A. faster B. with fewer resources C. with lower costs D. All of the above
Identify the letter of the choice that best matches the phrase or definition.
A. Used in MLA style instead of noting each source at the bottom of the page. B. The bibliographic list of sources at the end of an MLA-styled research paper. C. Text and graphics that prints at the top of each page in a document. D. Used to format text as you type it. E. Used to format and enter text, graphics, and other items. F. An identifier that links a citation to a source. G. Explanatory note that exists at the end of a document. H. A placeholder for data whose contents can change. I. Word feature that fixes errors as you type them in the document. J. Displays along the left edge of the Word window.
In the email address Kim_Lee@earthlink.net.us, Kim_Lee is the
A. domain B. URL C. site D. user ID E. location