From 2a547596045c126990211e9e3da1e3b2fc9fd04f Mon Sep 17 00:00:00 2001 From: kjg Date: Mon, 8 Jun 2020 22:29:05 +0900 Subject: [PATCH] [Python #7] create e39.py --- kjg/python-the-hard-way/e38.py | 17 +++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 kjg/python-the-hard-way/e38.py diff --git a/kjg/python-the-hard-way/e38.py b/kjg/python-the-hard-way/e38.py new file mode 100644 index 0000000..f1e1923 --- /dev/null +++ b/kjg/python-the-hard-way/e38.py @@ -0,0 +1,17 @@ +ten_things = "Apples Oranges Crows Telephone Light Sugar" + +print("Wait there are not 10 things in that list. Let's fix that.") + +stuff = ten_things.split(' ') +more_stuff = ["Day", "Night", "Song", "Frisbee","Corn", "Banana", "Girl", "Boy"] +while len(stuff) != 10: + next_one = more_stuff.pop() + print("Adding: ", next_one) + stuff.append(next_one) + print(f"There are {len(stuff)} items now.") + print("There we go: ", stuff) + print("Let's do some things with stuff.") + print(stuff[1]) + print(stuff[-1]) # whoa! fancy print(stuff.pop()) + print(' '.join(stuff)) # what? cool! + print('#'.join(stuff[3:5])) # super stellar! diff --git a/kjg/python.org b/kjg/python.org index 00f1762..46a7c3a 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -138,3 +138,5 @@ create calc.py *** Python #7 **** ex37 analysis sample codes +**** ex38 +append list