automate-boring-stuff/exercises/ex04/ex04a.py

18 lines
245 B
Python

"""
Practice Projects: Comma Code
Page 107
"""
def add(ls):
if len(ls) > 0:
ls = list(map(lambda x: str(x), ls))
ls[-1] = f"and {ls[-1]}"
print(", ".join(ls))
else:
print("")
add([0, 1, 2, 3])
add([])