Function Calling Python basic
<p>I'm trying to enter values from the tuple <code>('a',1), ('b',2),('c',3)</code> into the function <code>dostuff</code> but i always get a return of <code>None</code> or <code>False</code>. i'm new to this to i'm sorry if this question is basic. I would appreciate any help.</p>

<p>I expect the result of this to be:</p>

<pre><code>a1---8
b2---8 
c3---8
</code></pre>

<p>Code:</p>

<pre><code>def dostuff(stri,numb,char):
        cal = stri+str(numb)+'---'+str(char)
        return cal

def callit (tups,char):
    for x in range(len(tups)):
        dostuff(tups[x][0],tups[x][1],char)

print(callit([('a',1), ('b',2),('c',3)],8))
</code></pre>

<p>I think you're misunderstanding the <code>return</code> value of the functions: unless otherwise specified, all functions will return <code>None</code> at completion.  Your code:</p>

<pre><code>print(callit([('a',1), ('b',2),('c',3)],8))`
</code></pre>

<p>is telling the Python interpreter "print the return value of this function call."  This isn't printing what you expect it to because the <code>callit</code> function doesn't have a return value specified.  You could either change the <code>return</code> in your <code>dostuff</code> function like so:</p>

<pre><code> def dostuff(stri,numb,char):
    cal = stri+str(numb)+'---'+str(char)
    print cal

def callit (tups,char):
    for x in range(len(tups)):
        dostuff(tups[x][0],tups[x][1],char)

callit([('a',1), ('b',2),('c',3)],8)
</code></pre>

<p>This changes the return on the third line into a print command, and removes the print command from the <code>callit</code> call.
Another option would be:</p>

<pre><code> def dostuff(stri,numb,char):
    cal = stri+str(numb)+'---'+str(char)
    return cal

def callit (tups,char):
    for x in range(len(tups)):
        cal = dostuff(tups[x][0],tups[x][1],char)
        print(cal)


callit([('a',1), ('b',2),('c',3)],8)
</code></pre>

<p>This takes the return value from the <code>dostuff</code> function and stores it in a variable named cal, which could then be printed or written to a file on disk.</p>

python