From c8f538f9e7221279f0c10dc8a573f0e23969f63b Mon Sep 17 00:00:00 2001 From: kjg Date: Fri, 29 May 2020 23:24:20 +0900 Subject: [PATCH] [Python #6] create e36.py --- kjg/python-the-hard-way/e36.py | 29 +++++++++++++++++++++++++++++ kjg/python.org | 3 +++ 2 files changed, 32 insertions(+) create mode 100644 kjg/python-the-hard-way/e36.py diff --git a/kjg/python-the-hard-way/e36.py b/kjg/python-the-hard-way/e36.py new file mode 100644 index 0000000..53c4422 --- /dev/null +++ b/kjg/python-the-hard-way/e36.py @@ -0,0 +1,29 @@ +from sys import exit + +weapon = ['sword', 'gun', 'canon'] + + +def check_weapon(what): + if what == weapon[2]: + print("you win") + elif what == weapon[0]: + print("you lose") + elif what == weapon[1]: + print("you tie") + else: + print("you have to choose it in selection") + start() + + exit(0) + + +def start(): + while True: + print(f"you can choose weapon {weapon[0]}, {weapon[1]}, {weapon[2]}") + choice = input("> ") + check_weapon(choice) + + + + +start() diff --git a/kjg/python.org b/kjg/python.org index 09d173a..19204ce 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -124,9 +124,12 @@ How to use if, elif *** Python #6 **** ex32 How to use for-loop +append, insert, extend, copy, remove, pop, clear, count, index, reverse, sort **** ex33 How to use while-loop **** ex34 How to use Accessing Elements of Lists **** ex35 practice function, while, if +**** ex36 +some rules of if, loop and tips for debugging