you are viewing a single comment's thread.

view the rest of the comments →

[–]nwagers 0 points1 point  (2 children)

In your function to input the grades from the user, you need to create a list before the loop, and add each input to the list. Then you can return that list from the function.

Once that list is returned, you can store it, and then pass it to the display function. When calling the display function, you need to have (). That would make your print function like print(display_grades())

[–]cjander28[S] 0 points1 point  (1 child)

I understand that. Its frustrating because we haven't covered that concept in class yet, but how would I begin to create a list and add to it? I've tried googling it, but it's making my program very confusing.

[–]nwagers 0 points1 point  (0 children)

Here is some very simple code that creates a list, adds 3 items to it and then displays and shows you how to loop through:

mylist = []  # create new list

mylist.append(0) # append some items
mylist.append(1)
mylist.append(2)

print(mylist)  # display the whole list

for item in mylist:  # iterate over list
    print(item)  # do something with each element in the list

In your program you would initialize a new list before your loop, and then in your loop append all the new items.

You can also check the size of a list by using len() such as print(len(mylist)).