Novice python user need help passing data between functions
<p>I am finishing an assignment for a class where a teacher can input the student ID numbers and the students grades. The final grade will be calculated and returned next to the students number. I can calculate the final grade just fine, but I cannot append the grade to the list of student numbers. </p>

<pre><code>def assignments():
    assign1 = int(input("Assignment 1 grade: "))
    if assign1 &gt; 100:
        print ("Please input a valid grade value.")
        assign1 = int(input("Assignment 1 grade: "))
    assign2 = int(input("Assignment 2 grade: "))
    if assign2 &gt; 100:
        print ("Please input a valid grade value.")
        assign2 = int(input("Assignment 2 grade: "))
    assign3 = int(input("Assignment 3 grade: "))
    if assign3 &gt; 100:
        print ("Please input a valid grade value.")
        assign3 = int(input("Assignment 3 grade: "))
    assign4 = int(input("Assignment 4 grade: "))
    if assign4 &gt; 100:
        print ("Please input a valid grade value.")
        assign4 = int(input("Assignment 4 grade: "))
    assign5 = int(input("Assignment 5 grade: "))
    if assign5 &gt; 100:
        print ("Please input a valid grade value.")
        assign5 = int(input("Assignment 5 grade: "))
    assign6 = int(input("Assignment 6 grade: "))
    if assign6 &gt; 100:
        print ("Please input a valid grade value.")
        assign6 = int(input("Assignment 6 grade: "))
    assign7 = int(input("Assignment 7 grade: "))
    if assign7 &gt; 100:
        print ("Please input a valid grade value.")
        assign7 = int(input("Assignment 7 grade: "))
    assign8 = int(input("Assignment 8 grade: "))
    if assign8 &gt; 100:
        print ("Please input a valid grade value.")
        assign8 = int(input("Assignment 8 grade: "))
    assign9 = int(input("Assignment 9 grade: "))
    if assign9 &gt; 100:
        print ("Please input a valid grade value.")
        assign9 = int(input("Assignment 9 grade: "))
    assign10 = int(input("Assignment 10 grade: "))
    if assign10 &gt; 100:
        print ("Please input a valid grade value.")
        assign10 = int(input("Assignment 10 grade: "))
    assignGrade = assign1 + assign2 + assign3 + assign4 + assign5 + assign6 + assign7 + assign8 + assign9 + assign10
    aGrade = assignGrade / 10
    print("The final grade for all assignments is: ")
    print(aGrade)
    midterm = int(input("Midterm grade: "))
    if midterm &gt; 100:
        print ("Please input a valid grade value.")
        midterm = int(input("Midterm grade: "))
    finalExam = int(input("Final Exam grade: "))
    if finalExam &gt; 100:
        print ("Please input a valid grade value.")
        finalExam = int(input("Final Exam grade: "))
    testsGrade = midterm + finalExam
    tGrade = testsGrade / 2
    print("The final grade for all test is: ")
    print(tGrade)
    participation = int(input("Participation grade: "))
    if participation &gt; 100:
        print ("Please input a valid grade value.")
        participation = int(input("Participation grade: "))
    partGrade = participation
    print("The final grade for Participation is: ")
    print(partGrade)
    finalGrade = aGrade + tGrade + partGrade / 3


def students():
    netIDList = [] 
    maxLengthList = 6 
    while len(netIDList) &lt; maxLengthList:
        ID = input("Enter Student's Net ID: ")
        netIDList.append(ID)
    for s in netIDList:
        print("Please input grades for student " + s)
        assignments()
        f = assignments().finalGrade
        netIDList.append(": " + f)
    print(netIDList)

def main():
    students()

main()
</code></pre>

<p>Your problem is here:</p>

<pre><code>f = assignments().finalGrade
netIDList.append(": " + f)
</code></pre>

<p>You're accessing <code>assignments</code> like it is an object rather than a function.  You want to have <code>assignments</code> return a value to append.</p>

<pre><code>def assignments():
   # do all your input and calculation here
   finalGrade = aGrade + tGrade + partGrade / 3
   return finalGrade
</code></pre>

<p>This way, the function will send this value back to the place where it was called from.  Then, change</p>

<pre><code>f = assignments().finalGrade
</code></pre>

<p>to</p>

<pre><code>f = assignments()
</code></pre>

<p><strong><em>EDIT:</em></strong> Your for loop should look basically like this:</p>

<pre><code>for s in netIDList:
        print("Please input grades for student " + s)
        f = assignments()
        netIDList.append(": " + f)
</code></pre>

<p>but this will result in a somewhat confusing list: </p>

<pre><code>[student1_name, student2_name, student1_score, student2_score]
</code></pre>

<p>So I would use a dictionary:</p>

<pre><code>student_score_map = {}
for s in netIDList:
            print("Please input grades for student " + s)
            f = assignments()
            student_score_map[s] = f
</code></pre>

<p>This way you can print all student names <em>with their score</em> like so:</p>

<pre><code>for s in netIDList:
    print(s + ' final score:' + student_score_map[s])
</code></pre>

<p>Take a look <a class='doc-link' href="http://stackoverflow.com/documentation/python/396/dictionary#t=201608301912462219649">here</a> for more on dictionaries</p>

python function