-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay14 Higher or lower project.py
65 lines (36 loc) · 1.4 KB
/
Day14 Higher or lower project.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from art import logo, vs
from game_data import data
import random
def format_data(account):
account_name = account['name']
account_follower_count = account['follower_count']
account_description = account['description']
account_country = account['country']
return(f"{account_name}, a {account_description}, from {account_country}")
def check_answer(guess, A_follower_count, B_follower_count):
if A_follower_count > B_follower_count:
return guess == 'a'
else:
return guess == 'b'
print(logo)
score = 0
game_should_continue = True
account_B = random.choice(data)
while game_should_continue:
account_A = account_B
account_B = random.choice(data)
if account_A == account_B:
account_B = random.choice(data)
print(f"compare A: {format_data(account_A)}")
print(vs)
print(f"against B: {format_data(account_B)}")
guess = input("Who has more followers on instagram? Type 'A' or 'B': ").lower()
account_A_follower_count = account_A['follower_count']
account_B_follower_count = account_B['follower_count']
is_correct = check_answer(guess, account_A_follower_count, account_B_follower_count)
if is_correct:
score = score + 1
print(f"you are correct! current score is {score}")
else:
game_should_continue = False
print(f"you are wrong! Final score is {score}")