mardi 12 janvier 2021

I need help completing this random generator

I am having difficulty completing the code, it's a random generator - Question: "Create a text file named team.txt and store 8 football team names and their best player, separate the player from the team name by a comma. Create a program that reads from the text file and displays a random team name and the first letter of the player’s first name and the first letter of their surname."

teamList = open("team.txt", "w")
data = teamList._______()
randomChoice= random._______(____)
teamName =[barcelona, chelsea, united, liverpool, city, tottenham, arsenal, westham]
player = [messi, beckham, rooney, suarez, silva, kane, henry, rice]
for lines in data:
    split = lines.append(',')
    teamName.sort(split[0])
    player.sort(split[1])
teamName = teamName[randomChoice]
letters = player[randomChoice]
print("\nThe team is ",teamName) 
splitLetters = letters._____(' ')
print("And the first letter of the player’s firstname and surname is")
for x in range(_____(splitLetters)):
    print((______[x][_]).upper())



Aucun commentaire:

Enregistrer un commentaire