Simple, random encounters in a python text-adventure.. IÂ´m stuck
<p>i recently started simple coding with python 3 and iÂ´m stuck with a simple problem:</p>

<hr>

<pre><code>import random

def enemy_bandit01():
     bandit01 = {'race': 'human', 'weapon': 'a sword'}

def enemy_orc01():
     orc01 = {'race': 'orc', 'weapon': 'a club'}

def enemy_wolf01():
     wolf01 = {'race': 'wolf', 'weapon': 'claws'}

encounter_choice = [enemy_bandit01, enemy_orc01, enemy_wolf01]

print('You fight against a ____. He has ____!')
</code></pre>

<hr>

<p>I simply want python to pick a random enemy_x - function and then print out a text which includes the race/weapon etc.. without writing a new text for every enemy.</p>

<p>I am aware that this is a noob question, but i was not able to figure this out by myself.</p>

<p>the dicts and your functions are really pointless as they are, they need to actual return something so you can randomly pick a pair:</p>

<pre><code>from random import choice # use to pick a random element from  encounter_choice

def enemy_bandit01():
    return 'human', 'a sword' # just return a tuple


def enemy_orc01():
    return 'orc', 'a club'


def enemy_wolf01():
    return 'wolf', 'claws'


encounter_choice = [enemy_bandit01, enemy_orc01, enemy_wolf01]

# use str.format and unpack the tuple of race, weapon
print('You fight against a {}. He has {}!'.format(*choice(encounter_choice)()))
</code></pre>

<p>which may as well just become picking a random tuple from a list:</p>

<pre><code>from random import choice

encounter_choice = [('human', 'a sword'), ( 'orc', 'a club'), ('wolf', 'claws') ]

print('You fight against a {}. He has {}!'.format(*choice(encounter_choice)))
</code></pre>

<p><code>*choice(encounter_choice)</code> is equivalent to doing:</p>

<pre><code>race, weapon = choice(encounter_choice)
print('You fight against a {}. He has {}!'.format(race, weapon))
</code></pre>

python python-3.x random