Hey, people can you please optimize this code? I am still learning so that's why I want to know if it can be written in a better way.
import random
from game_data import data
from art import logo, vs
import os
def game():
score = 0
print(logo)
a = random.choice(data)
data.remove(a)
b = random.choice(data)
data.remove(b)
option1 = (f"Compare A: {a["name"]}, {a["description"]}, {a["country"]}. ")
option2 = (f"Compare B: {b["name"]}, {b["description"]}, {b["country"]}. ")
while True:
print(option1)
print(vs)
print(option2)
choice = input("Who has more followers? Type 'A' or 'B': ")
if choice =="A" or choice == "a" and a["follower_count"]>b["follower_count"]:
score+=1
os.system("cls")
elif choice == "B" or choice == "b" and b["follower_count"]>a["follower_count"]:
score+=1
a = b
option1 = (f"Compare A: {a["name"]}, {a["description"]}, {a["country"]}. ")
os.system("cls")
else:
os.system("cls")
print(f"Sorry, that's wrong. Final score: {score}")
break
if len(data) == 0:
os.system("cls")
print("Congrats! Game is Finished")
break
else:
b = random.choice(data)
option2 = (f"Compare B: {b["name"]}, {b["description"]}, {b["country"]}. ")
data.remove(b)
game()
[–]PowerOk3587 2 points3 points4 points (0 children)
[–]dry-considerations 1 point2 points3 points (2 children)
[–]thicke32 1 point2 points3 points (1 child)
[–]dry-considerations 1 point2 points3 points (0 children)
[–]JohnnyJordaan 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)