I'm trying to build a program that will pick a random items (just once for each) from a list, that was imported from a file. NB: I put only one item for a line in my file (no space, no coma, nothing else than a simple word)
I have a code like that for now:
file = open('file.txt', 'r')
myList = file.readlines()
myList[0]
rand_item = random.choice(myList)
print (rand_item)
I am just at the beginning of my program, so I'm just testing every new step that i make. Here, I'd like to display a random item from my list (itsefl imported from a file).
I have this message when I try to run my program:
Traceback (most recent call last):
File "C:/Users/Julien/Desktop/test final.py", line 16, in <module>
rand_item = random.choice(listEmployee)
AttributeError: 'builtin_function_or_method' object has no attribute 'choice'