Hi Steve, thank you so much for your prompt reply. sorry i'm sending another email as i haven't learnt how to replly to the posts properly yet.
I've had a go at implementing a list, but all i get is: It looks as though it is appending all three values together rather than seperatly.. Please enter the number of grades:3 Please enter the grade:60 Please enter the grade:90 Please enter the grade:50 [60, 90, 50] [60, 90, 50] [60, 90, 50] I have added this code: Initialised the list under def main() grades = [] added under the while loop: grades.append(grade) This is now my for statement for i in range (numberOfGrades): determine_grade(grade, i) print grades I feel so close yet so far on this one! I've changed variable, i don't think its appending to the list correctly? Should i be placing the grades.append(grade) under def main()? Although it needs to add to the list after each iteration.... any advice is appreciated. Thanks again, Krystal :) Krystal Brosz wrote: > Hi there,> > i'm struggling with a program, i feel like i am really close to getting it> but i cannot find a way to use the target variables inside of a loop:> I'm trying to get the program to ask the user, how many grades are you going> to enter. Then i want to work out the average which is fine. But then i> want the loop to print out from each grade entered the letter grade as per> my if statement. All it does is print the last grade out a certain number> of times. Is this even possible or am i overthinking it? No, you're not over-thinking it, but you do have a few small errors in your code: > Some code is:> def main():> > gradesEntered = 0> score = 0> numberOfGrades = 0> #get the number of grades being checked> numberOfGrades = int(raw_input("Please enter the number of grades:" ))> > #Begin a 'for' loop to enter each score> while numberOfGrades != gradesEntered:> grade = int(raw_input("Please enter the grade:" ))> gradesEntered += 1> score =+ grade> grade = [numberOfGrades] Here you ask the user to enter a grade. Suppose they enter (say) 75. Your program will store 75 in grade, and then a moment later over-write that by storing [numberOfGrades] in grade. I believe that what you need is to have a variable "grades" (note plural), and each time around the while loop, you need to append the current grade to the grades list. Then, after you have collected all the grades, you can iterate over the list to get each grade one at a time: for grade in grades: print grade See how you go with that, and don't hesitate to ask if anything is unclear! -- Steven
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor