Aug-12-2019, 01:14 AM
(This post was last modified: Aug-12-2019, 01:16 AM by boring_accountant.)
Ah ! Here is the error:
Here is a short example that should demonstrate what I mean:
for pirates in pirates: # <-- This line is the bad guy print pirates # Attacks List attack = ['Dodge', 'Parry', 'Thrust'] print'''What this does is it cycles through values in the list named pirates and puts the result in a string called pirates. This effectively replaces the initial list with a string. When you call random.choice(), it is correctly applied on a string, which will return a random letter from the last word in the initial pirates list.
Here is a short example that should demonstrate what I mean:
test = ['abc', 'def'] for test in test: print(test) print(test) print(random.choice(test))
Output:abc
def
def
e
If rename my initial variable from test to tests, here is the resulting code and output:tests = ['abc', 'def'] for test in tests: print(test) print(tests) print(random.choice(tests))
Output:abc
def
['abc', 'def']
def
Hope this helps.