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>You can use a list comprehension to do it in one line:</p>

<pre><code>char = 8
point_list = [('a', 1), ('b', 2),('c', 3)]
print("\n".join(["{}{}---{}".format(s, n, char) for s, n in point_list]))
</code></pre>

<p><code>"{}{}---{}".format(s, n, char)</code> creates a string by replacing <code>{}</code> by each one of the input in <code>format</code>, therefore <code>"{}{}---{}".format("a", 1, 8)</code> will return <code>"a1---8"</code></p>

<p><code>for s, n in point_list</code> will create an implicit loop over the <code>point_list</code> list and for each element of the list (each tuple) will store the first element in <code>s</code> and the second in <code>n</code></p>

<p><code>["{}{}---{}".format(s, n, char) for s, n in point_list]</code> is therefore a list created by applying the format we want to each of the tuples: it will return <code>["a1---8","b2---8","c3---8"]</code></p>

<p>finally <code>"\n".join(["a1---8","b2---8","c3---8"])</code> creates a single string from a list of strings by concatenating each element of the list to "\n" to the next one: <code>"a1---8\nb2---8\nc3---8"</code> (<code>"\n"</code> is a special character representing the end of a line</p>

python