Saint Louis University |
Computer Science 150
|
Dept. of Math & Computer Science |
Topic: Flow of Control
Related Reading: Zelle 2.6, Ch. 7, 8.4
Due:
1:10pm, Tuesday 4 October 2005
Please make sure you adhere to the policies on academic integrity.
For both of these problems, you could always type in the specified code fragments and let Python answer the questions for you, however you are strongly advised to first attempt these problems by hand! (as these are the type of problems which might be seen on an exam)
Zelle's Chapter 2, "Discussion" question 4 (page 48)
Zelle's Chapter 7, "Discussion" question 2 (pages 227-228)
Write a code fragment which takes a list items and prints out all values which occur more than once on the list. Take care to only print out each such value once.
For example, given the list:
items = ['apple','grapes','kiwi','kiwi','pear','grapes','kiwi', 'strawberry']
Your program should print:
grape
kiwi
(or kiwi, grape; the order is up to you).