-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay-14-The Higher Lower Game.py
49 lines (40 loc) · 1.26 KB
/
Day-14-The Higher Lower Game.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
My Code : https://replit.com/@saichandratejas/higher-lower-start
Solution:
from art import logo, vs
from game_data import data
import random
from replit import clear
def format_data(account):
account_name=account['name']
account_description=account['description']
account_country=account['country']
return(f'{account_name} ,\tis a {account_description} ,\tfrom {account_country}.')
def check_answer(guess,a_followers,b_followers):
if a_follower_count >b_follower_count:
if guess=='a':
return guess=='a'
else:
return guess=='b'
clear()
print(logo)
score=0
game=True
account_b=random.choice(data)
while game:
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 'A' or 'B'?! ").lower()
a_follower_count=account_a['follower_count']
b_follower_count=account_b['follower_count']
is_correct=check_answer(guess,a_follower_count,b_follower_count)
if is_correct:
score+=1
print(f"You are right!, Current Score is {score}")
else:
game = False
print(f"You are wrong!, Current Score is {score}")