Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

import random from PIL import Image Define the artists and their monthly Spotify…

  1. User

    import random from PIL import Image

    Define the artists and their monthly Spotify listeners

    artists = {

    'Young Nudy': {"image":"./fotos/Young Nudy_1.jpeg", "listeners": 7553116},
    
    'Young Thug': {"image":"./fotos/Young Thug_1.jpeg", "listeners": 28887553},
    
    'Yungeen Ace': {"image":"./fotos/Yungeen Ace_1.jpeg", "listeners": 1294188},
    

    }

    while True: score = 0 # reset score at the beginning of each game first_artist, second_artist = random.sample(list(artists.keys()), 2)

    # Load the images for the artists
    first_artist_image = Image.open(artists[first_artist]["image"])
    second_artist_image = Image.open(artists[second_artist]["image"])
    
    while True:
        # Display the images
        image.show(first_artist_image)
        image.show(second_artist_image)
    
        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 not in ['1', '2', first_artist.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() or guess_lower == '1' and artists[first_artist]["listeners"] > artists[second_artist]["listeners"]:
            print(f"You guessed correctly! {first_artist.title()} had {artists[first_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners and {second_artist.title()} has {artists[second_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners.")
            score += 1
            first_artist, second_artist = random.sample(list(artists.keys()), 2)  # select new artists for the next round
    
            # Load the images for the new artists
            first_artist_image = Image.open(artists[first_artist]["image"])
            second_artist_image = Image.open(artists[second_artist]["image"])
            continue
    
        elif guess_lower == second_artist.lower() or guess_lower == '2' and artists[second_artist]["listeners"] > artists[first_artist]["listeners"]:
            print(f"You guessed correctly! {second_artist.title()} had {artists[second_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners and {first_artist.title()} has {artists[first_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners.")
            score += 1
            first_artist, second_artist = random.sample(list(artists.keys()), 2)  # select new artists for the next round
    
            # Load the images for the new artists
            first_artist_image = Image.open(artists[first_artist]["image"])
            second_artist_image = Image.open(artists[second_artist]["image"])
            continue
    
        else:
            print(f"\nSorry, you guessed incorrectly. {first_artist.title()} had {artists[first_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners and {second_artist.title()} has {artists[second_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners.\n")
            print(f"Your final score is {score}.")
            play_again = input("Would you like to play again? (y/n) ")
            if play_again.lower() == 'n':
                print("Thanks for playing!")
                quit()
            else:
                score = 0
                first_artist, second_artist = random.sample(list(artists.keys()), 2)  # select new artists for the next round
    
                # Load the images for the new artists
                first_artist_image = Image.open(artists[first_artist]["image"])
                second_artist_image = Image.open(artists[second_artist]["image"])
                break
    

    why dont the images open

  2. Assistant

    There could be several reasons why the images don't open. Here are some possible reasons and their solutions:

    1. Wrong file path: If the file paths for the images are incorrect, the program won't be able to locate and open them. Make sure that the file paths are correct and that the image files are in the specified folders.

    2. Incorrect file format: The PIL library can open many different file formats, such as JPEG, PNG, BMP, etc. Make sure that the images you are trying to open are in a format that PIL can handle.

    3. Issues with PIL installation: If PIL is not installed correctly or is missing dependencies, it may not be able to load the images. Try reinstalling or updating PIL and make sure that all dependencies are installed.

    4. Issues with the image files: If the image files themselves are corrupt or missing important data, PIL may not be able to open them. Try opening the images in a different program to make sure that they are not corrupted.

    If none of these solutions work, try printing out debugging messages or using a debugger to pinpoint the exact issue.