This program works fine but I'm having trouble removing the blank lines after every player. I've tried to use .strip but I get the error 'list' object has no attribute 'strip'
def random_player(datafile):
import random
read_mode = "r"
with open (datafile, read_mode) as read_file:
the_line = read_file.readlines()
print(random.choice(the_line))
read_file.close
(random_player(file_name))
(random_player(file_name))
(random_player(file_name))
(random_player(file_name))
(random_player(file_name))
What I get:
Toney Douglas
Adonal Foyle
Nate Hawthorne
Joe Stephens
Gary Payton II
What I want:
Toney Douglas
Adonal Foyle
Nate Hawthorne
Joe Stephens
Gary Payton II
Aucun commentaire:
Enregistrer un commentaire