Below is the code i have created for a music quiz game, firstly i need to know how to print the first letter of each song, and fix the while statement :)
--------------------------------------------------------------------
P.S These are the songs in my external file:
Thanks,
Lynden
--------------------------------------------------------------------
import random songs = [] f = open("Songs.txt", "r") wrong = 0 songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) songs.append(f.readline()) counter = 0 while counter <= 9: print(random.choice(songs)) answer = input("Guess the song!") if answer == songs[counter]: print("Correct") counter += 1 else: print("Incorrect") wrong += 1-----------------------------------------------------------
P.S These are the songs in my external file:
Output:New_Patek_Lil_Uzi_Vert
Despacito_Luis_Fonsi
Rap_Devil_MGK
Killshot_Eminem
Lucky_You_Eminem_&_Joyner_Lucas
Maskoff_Future
Rockstar_Post_Malone
I_Love_It_Kanye_West_&_Lil_Pump
Its_Everyday_Bro_Jake_Paul
Venom_Eminem
^------- these are correct, please do not change, it just needs to print the first letter, not the whole line :)Thanks,
Lynden