CSCI-101: Intro to Computer Science
Python Course

Tasty Foods (Set Example)

1
2
3
4
5
6
7
8
# Title: Tasty Foods (Set Example)
food = set()      # this creates an empty set
while True:
    line = input('Give a tasty food, blank to end: ')
    if line == '':
        break     # exits the while loop
    food.add(line)
print('You think', len(food), 'foods are tasty')