Hi again,
I've made a function that creates a dictionary. In my previous thread/question, Andrew Jaffe writes this:
"In addition to all of the other hints and tips, I think you're missing something crucial: your functions actually need to return something. When you create autoparts() or splittext(), the idea is that this will be a function that you can call, and it can (and should) give something back. Once you figure out the output that you want your function to have, you need to put it in a return statement."
With the help from this forum, I now have this function:
def autoparts():
parts_dict={}
list_of_parts = open('list_of_parts.txt', 'r')
for line in list_of_parts:
k, v = line.split()
parts_dict[k] = v
This function creates a dictionary, but it does not return something. I could have added print parts_dict, and it would have returned the dictionary. I dont see the difference between the return statement and that the function prints out the dictionary. Can someone please explain this to me?