-
Notifications
You must be signed in to change notification settings - Fork 0
/
human.py
29 lines (22 loc) · 1.11 KB
/
human.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Human:
def takeTurn(self, piles):
print("It's your turn human!\nSelect which pile you would like to remove from, then the amount separated by a space:")
while True:
try:
response = list(map(int, input().split()))
except ValueError:
print("[ERROR]: Please ensure you are only entering integers with no other characters. Try again:")
continue
if len(response) != 2:
print("[ERROR]: Please ensure you are entering two values. Try again:")
continue
if response[0] < 1 or response[0] > len(piles):
print("[ERROR]: There is no pile {}. Try again:".format(response[0]))
continue
if response[1] < 1 or response[1] > piles[response[0] - 1]:
print("[ERROR]: Invalid amount for that pile. Try again:")
continue
else:
return response[0] - 1, response[1]
def victoryMessage(self):
print("\nWe have a winner! The human has defeated the evil robot.")