How do I use raw input inside a function
<p>I have scoured the forum trying to find a good way to make a function that takes raw input and uses it.</p>

<pre><code>print "Roll for Agility"

def Rolling(a, b, value):

    in1 = raw_input()

    if in1 == 'roll':

        irand = randrange(a, b)

    elif in1 == 'Roll':

        irand = randrange(a, b)

    else: 

        print "Please Type &lt;roll&gt; in order to roll the dice."

        Rolling ()

    print "Your %d is %d" % (value, irand)

Rolling(1, 10, Agility)
</code></pre>

<p>It's supposed to take the numbers for the rolling range, and the number in the roll is inserted into a value (Agility in this case).</p>

<p>The code doesn't work because there's a problem with the raw input and the arguments put inside "Rolling function". I want the function not only to take raw input but also process it. I don't want to make raw input before the function and later add it manually into the function by putting the raw input into a string or int.</p>

<p>Thanks in advance!</p>

<p>The code has some typos. Error message <code>NameError: name 'value' is not defined</code> is generated because that statement has been mistakenly put outside the <code>Rolling</code> function body where <code>value</code> is not defined.</p>

<p>Corrected code should look like:</p>

<pre><code>#Rolling for Agility
from random import randrange
print "Roll for Agility"
def Rolling(a, b, value):
    in1 = raw_input()
    if in1 == 'roll' or in1 == 'Roll':
        irand = randrange(a, b)
        print "Your %s is %d" % (value, irand) 
    else: 
        print "Please Type &lt;roll&gt; in order to roll the dice."
        Rolling(a,b,value) # using recursion to call again incase of erroneous input 


Rolling(1, 10, "Agility")
</code></pre>

python