From 75a42ec54dbf721caa659ddf02c1f46fc2cb4bef Mon Sep 17 00:00:00 2001 From: mlot Date: Fri, 6 Jun 2025 13:40:57 -0400 Subject: initial commit for archiving --- Chap4PracComma.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Chap4PracComma.py (limited to 'Chap4PracComma.py') 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) -- cgit