Looping and saving multiple inputs
<p>I'm trying to loop through a set of inputs where I ask for a user's course grade, course hours and course code. The loop keeps on repeating until the user enters "done". Once the user has entered done I want it to print out the entered courses with grade and hours. </p>

<p>For Example: </p>

<pre><code>course_count = False

#LOOP through Inputs
while not course_count:

    #GET course code
    course_code = input( "Please Enter the Course Code (or done if finished): " )

    #IF course code is not equal to done (convert to lowercase)
    if course_code.lower() != "done":

        #GET course hours
        course_hours = int( input( "How many credit hours was " + course_code + "? " ) )

        #GET grade earned
        course_grade = float( input( "What grade did you earn in " + course_code + "? " ) )

    #ELSE END LOOP
    else:
        course_count = True

    print("Course: " + course_code + " Weight: " + str( course_hours ) + " hours " + "Grade: " + str( course_grade ) + "%")
</code></pre>

<p>The problem is it will always print out only one inputted course, hour and grade. How would I save more than one answer using only accumulative strings? </p>

<p>The output I'm looking to make is:</p>

<pre><code># Please Enter the Course Code (or done if finished): COMP 10001
# How many credit hours was COMP 10001? 5
# What grade did you earn in COMP 10001? 75

# Please Enter the Course Code (or done if finished): COMP 20002
# How many credit hours was COMP 10001? 8
# What grade did you earn in COMP 10001? 95

# Please Enter the Course Code (or done if finished): done

# Course: COMP 10001 Weight: 5 Grade: 75%
# Course: COMP 20002 Weight: 8 Grade: 95%
</code></pre>

<p>It's for a school practice problem and were not allowed to use lists, arrays or dictionaries if that makes sense</p>

<p>See if you can relate this simplified example to your code. To get the output you describe, you need to <em>store</em> the output text somehow and access it later:</p>

<pre><code>output_lines = []

for i in range(10):
  input_string = input("Enter some input")
  output_lines.append(input_string)

for output_line in output_lines:
  print(output_line)
</code></pre>

<p>From the comments, using only string "accumulation" (warning: quadratically bad):</p>

<pre><code>output_text

for i in range(10):
  input_string = input("Enter some input")
  output_text = output_text + '\n' + input_string
print(output_text)
</code></pre>

<p>Note that the preferred way to build up a long string <em>is</em> to append to a list and use <code>'separator'.join(list_of_strings)</code> or print one-by-one as above.</p>

python