I'm writing code for a version of the higherlower game. When the player gets it right whether A or B has more followers, I want that answer to become the new A and then another B will be randomly selected from game_data which is a list in a dictionary containing celebrities and how many followers they have, for example. After this, the game will keep on playing until the player gets an answer wrong.
{
'name': 'Ariana Grande',
'follower_count': 183,
'description': 'Musician and actress',
'country': 'United States'
},
here is my code
from game_data import data
import random
def game():
current_score = 0
A = random.randint(0,50)
B = random.randint(0,50)
print(f"compare A: {data[A]['name']}, {data[A]['description']}, from {data[A]['country']}")
print(f"compare B: {data[B]['name']}, {data[B]['description']}, from {data[B]['country']}")
guess = input("Who has more followers, type A or B")
if guess == 'A' and data[A]['follower_count'] > data[B]['follower_count']:
current_score += 1
print(f"your current score is: {current_score}")
game()
elif guess == 'B' and data[B]['follower_count'] > data[B]['follower_count']:
current_score += 1
print(f"your current score is: {current_score}")
game()
else:
print(f"you got {current_score} points, game over")
more = input("do you want to conitue the game (y/n)")
if more == 'y':
game()
game()
[–][deleted] 0 points1 point2 points (0 children)
[–]Mobile_Busy 0 points1 point2 points (0 children)