diff options
Diffstat (limited to 'Chap4PracComma.py')
-rw-r--r-- | Chap4PracComma.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Chap4PracComma.py b/Chap4PracComma.py new file mode 100644 index 0000000..6c2a6b1 --- /dev/null +++ b/Chap4PracComma.py @@ -0,0 +1,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) |