See What I Have Learned!

Hello fellows!

At this point my self-study Python course, assigned to me by my great mentor Michael, has done finally. I can’t say that I have learned everything of python certainly, however indeed, from knowing zero of Python, I have learned a lot, I can say that I know the basic ideas of Python now, which is great! Well, how about I just share the last question of the very interesting final project of the course with all of you here in this blog? It must be very easy and simple for many of you, and all mentors of course, :) but to me, it took me a long time to figure it out, although the code is actually not long at all! :( And felt good to be able to solve a question in Python!

Ok, here is the description of the interesting question: create a procedure, find_path_to_friend:

Interestingly, this seems to be a kind of popular homework question in Python study, as I found quite some discussions about it on the internet, which actually helped me to get my answer eventually.

In the “Arguments” part of the description, another procedure: create_data_structure is mentioned, which is a procedure used to generate the friendship network used as one of the input arguments of this find_path_to_friend procedure. It has been done under the guide of my mentor Michael, and the result of it is a list of dictionaries, containing the friend connections of the system users and the games liked by each of the users. The result network data structure looks like this: [{user:[friend connections]}, {user:[games liked]}].

And here is the original input string of create_data_structure, from which the friendship network is generated:

So, based on the friendship network result generated by the create_data_structure procedure, which is a list of 2 dictionaries, I finally got the code as follows:

Done! It is really not long, right? However, it took me a lonnnnng time to figure it out:(, and of course with the help of my mentor too, but it was fun! Also, I believe this is only one kind of solutions of this problem, I really like to hear your ideas, my fellows! Please contribute your ideas, I would really appreciate any different solutions for this question! — I surely like to learn from you! :))

Show your support

Clapping shows how much you appreciated Lynn’s story.