[Python #6] create e36.py
This commit is contained in:
parent
b7fc736894
commit
c8f538f9e7
2 changed files with 32 additions and 0 deletions
29
kjg/python-the-hard-way/e36.py
Normal file
29
kjg/python-the-hard-way/e36.py
Normal file
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue