summaryrefslogtreecommitdiff
path: root/Chap4PracComma.py
blob: 6c2a6b1790483409c271e60920bb21c111d4e1e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# !Python
 
# Chapter 4 practice projects
 
def eggs(listvalue):
    for i in range(len(listvalue)):
        print(listvalue[i] + ', ', end="")
        if listvalue[i] == listvalue[-2]:
            print('and ' + listvalue[-1], end="")
            break
 
 
spam = ['apples','bananas','tofu','cats']
eggs(spam)