Untitled
unknown
plain_text
a year ago
2.8 kB
12
Indexable
import random
import time
data = [
{
"name" : "Christiano Ronaldo",
"followers" : 627,
"description" : "footballer"
},
{
"name" : "Rihanna",
"followers" : 152,
"description" : "singer"
},
{
"name" : "Joe Biden",
"followers" : 19.2,
"description" : "president"
},
{
"name" : "Selena Gomez",
"followers" : 429,
"description" : "singer"
},
{
"name" : "Instagram",
"followers" : 672,
"description" : "social media platform"
},
{
"name" : "Kim Kardashian",
"followers" : 364,
"description" : "media personality"
},
{
"name" : "Nike",
"followers" : 307,
"description" : "brand"
},
{
"name" : "LeBron James",
"followers" : 159,
"description" : "basketball player"
},
{
"name" : "FC Barcelona",
"followers" : 126,
"description" : "football team"
},
{
"name" : "Vin Diesel",
"followers" : 152,
"description" : "actor"
},
{
"name" : "NBA",
"followers" : 87.5,
"description" : "basketball league"
},
{
"name" : "Jennifer Lopez",
"followers" : 253,
"description" : "singer"
},
{
"name" : "Dwayne Johnson",
"followers" : 398,
"description" : "actor"
},
{
"name" : "Zendaya",
"followers" : 184,
"description" : "actress"
},
{
"name" : "Snoop Dogg",
"followers" : 86.5,
"description" : "rapper"
}
]
while True:
item1 = random.choice(data)
item2 = random.choice(data)
while item1 == item2:
item2 = random.choice(data)
while True:
account1 = f"{item1['name']}, {item1['description']}"
account2 = f"{item2['name']}, {item2['description']}"
print(f"Compare:\n\n{account1}\n\nwith\n\n{account2}")
guess = input("Who has more followers? 1 or 2? (or type 'exit' to quit)\n")
if guess.lower() == 'exit':
exit()
if guess == '1':
if item1["followers"] > item2["followers"]:
print(f"\nYou are correct!\n\n{item1['name']} has {item1['followers']}M followers and {item2['name']} has {item2['followers']}M followers")
else:
print(f"\nYou are NOT correct.\n\n{item1['name']} has {item1['followers']}M followers and {item2['name']} has {item2['followers']}M followers")
time.sleep(2)
break
elif guess == '2':
if item1["followers"] < item2["followers"]:
print(f"\nYou are correct!\n\n{item1['name']} has {item1['followers']}M followers and {item2['name']} has {item2['followers']}M followers")
else:
print(f"\nYou are NOT correct.\n\n{item1['name']} has {item1['followers']}M followers and {item2['name']} has {item2['followers']}M followers")
time.sleep(2)
break
else:
print("Invalid input. Please enter 1 or 2.")
print("\n")Editor is loading...
Leave a Comment