import random artistslisteners = { 'Young Thug': 28887553, 'Yungeen Ace': 1294188, }…
- User
import random
artists_listeners = { 'Young Thug': 28887553, 'Yungeen Ace': 1294188, }
keys = list(artists_listeners.keys())
score = 0
while True: first_artist = random.choice(keys) second_artist = random.choice(keys)
while first_artist == second_artist: second_artist = random.choice(keys)
while True: guess = input(f"\nWhich artist has more monthly Spotify listeners - 1. {first_artist.title()} or 2. {second_artist.title()}? ") guess_lower = guess.strip().lower()
if guess_lower == 'quit': print("Thanks for playing!") quit() elif guess_lower != first_artist.lower() and guess_lower != second_artist.lower(): print("Invalid input. Please enter the name of one of the two artists or 'quit' to end the game.") elif guess_lower == first_artist.lower() and artists_listeners[first_artist] > artists_listeners[second_artist]: print(f"You guessed correctly! {first_artist.title()} had {int(artists_listeners[first_artist] / 1e6):,}M monthly Spotify listeners and {second_artist.title()} has {int(artists_listeners[second_artist] / 1e6):,}M monthly Spotify listeners.") score += 1 break elif guess_lower == second_artist.lower() and artists_listeners[second_artist] > artists_listeners[first_artist]: print(f"You guessed correctly! {second_artist.title()} had {int(artists_listeners[second_artist] / 1e6):,}M monthly Spotify listeners and {first_artist.title()} has {int(artists_listeners[first_artist] / 1e6):,}M monthly Spotify listeners.") score += 1 break else: print(f"\nSorry, you guessed incorrectly. {first_artist.title()} had {int(artists_listeners[first_artist] / 1e6):,}M monthly Spotify listeners and {second_artist.title()} has {int(artists_listeners[second_artist] / 1e6):,}M monthly Spotify listeners.\n") score = 0 play_again = input("Would you like to play again? (y/n) ") if play_again.lower() == 'n': print("Thanks for playing!") quit()print(f"\nYour score is {score}." can you change it so that the player can give both the name of the artist or the number 1 or 2, not every artist should have their own number
- Assistant
Sure! Here's the updated code:
import random
artists_listeners = { 'Young Thug': 28887553, 'Yungeen Ace': 1294188, }
- User
where is the part where the game checks the if the given number is correct
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.