My code is wrong? I can’t seem to find the answer [closed]

Question is:

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.

syntax error image here

import random
teamList = open("team.txt", "r")
data = teamList.readlines()
randomChoice = random.choice(range(8))
teamName =[["arsenal"],["tottenham"],["chelsea"],["westham"],["city"],["united"],["barcelona"],["liverpool"]]
player =[["kane"],["messi"],["ronaldo"],["ronaldino"],["ibrahimovic"],["neymar"],["salah"],["hazard"]]
for lines in data:
    split = lines.split(',')
    teamName.append(split[0])
    player.append(split[1])
teamName = teamName[randomChoice]
letters = player[randomChoice]
print("nThe team is ", teamName)
splitLetters = letters.append('')
print("And the first letter of the player’s firstname and surname is")

for x in range(len(splitLetters)):
    print((splitLetters[x][0]).upper())

Answer

The issue is with this line:

splitLetters = letters.append('')

The issue is .append() does not return any value, so splitLetters is None and therefore doesn’t have a length. To use .append(), you need to append directly to the string (i.e letters.append(‘t’) would append the string ‘t’ to letters, but wouldn’t return a value)

However, this is not necessary since you are appending an empty string ” to letters. Try removing the line splitLetters = letters.append('') changing the second last line to:

for x in range(len(letters)):