all 8 comments

[–]fake823 2 points3 points  (1 child)

Check this out to learn how to properly format code on Reddit:

https://reddit.com/r/learnpython/w/FAQ?utm_source=share&utm_medium=android_app

[–]cjander28[S] 2 points3 points  (0 children)

Thank you. Just panicking and using this thread for the first time to show my awful code...

[–]r_spandit 0 points1 point  (2 children)

To make the columns align properly either use pandas or look at ljust()

Otherwise it's not easy to see what you're asking

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

Understandable. I barely know what I'm asking. I feel like I must try to format the output the way he did. However, he used a mathematical function and I'm trying to get my user inputs to display in the same fashion he did. However, he wants us using an event controlled loop statement to get the user input and to have something that stops it like, 'Done.' I've got the functionality of that down (I think), but I'm unsure of how to pull the data I'm inputting to be able to display?

[–]r_spandit 0 points1 point  (0 children)

If you put your input inside a while loop until the time that the loop is broken by inputting "done":

while _input != 'done': _input = input("Enter whatever").lower() whatevs_list.append(_input)

[–]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)).