gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
can you see whats wrong in my code import random artistslisteners = { 'Lil Baby':…
- User
can you see whats wrong in my code import random
codeartists_listeners = { 'Lil Baby': 58738173, 'Roddy Ricch': 34447081, 'DaBaby': 29659518, 'Polo G': 27204041, 'NLE Choppa': 11423582, 'Lil Tjay': 16873693, 'Lil Durk': 19827615, 'Megan Thee Stallion': 26685725, 'Pop Smoke': 32169881, 'Lizzo': 9236657, 'Migos': 23242076, 'Doja Cat': 33556496, 'Tyler, The Creator': 11459242, 'Saweetie': 10217413, 'Cordae': 4026278, 'Juice WRLD': 42092985, 'Travis Scott': 52627586, 'Post Malone': 65466387, 'Drake': 71588843, 'Kendrick Lamar': 33841249, 'J. Cole': 38726509, 'Kanye West': 29204328, 'Lil Nas X': 23824455, '21 Savage': 26764030, 'Lil Uzi Vert': 40941950 } # Select a random artist and its listener count artist, count = random.choice(list(artists_listeners.items())) # Game loop while True: # Ask player to guess higher or lower guess = input(f"Is the listener count for {artist} higher or lower than {count}? (h/l): ") # Select a new artist and listener count new_artist, new_count = random.choice(list(artists_listeners.items())) # Check player's guess if (guess == 'h' and new_count > count) or (guess == 'l' and new_count < count): print('Correct!') artist, count = new_artist, new_count else: print('Incorrect!') print(f"The correct answer was {artist} with {count} listeners.') break print('Thanks for playing!')i think the problem is in line37
- Assistant
Yes, the problem is in line 37. The break statement is not properly indented and is outside of the while loop. It should be indented to the same level as the if statement above it, so that it is executed within the loop when the player guesses incorrectly.
- User
can you correct line 37?
- Assistant
Sure, here is the corrected code with line 37 properly indented:
python