As I blogged a while ago, I was planning on better learning Python and programming in general. Every once and a while I’ve been doing a tutorial, but there’s been no significant progress really. The last few days, I’ve been working on understanding the manipulation of lists and dictionaries in Python. These two aspects are essential for my little project of practicing vocabulary words for German.
I had been trying to find a way to iterate through a list of items, each of which contained both a german word and its english translation. I kept getting errors, and I finally figured out that these items are called “tuples”, and thus, have to be manipulated in a slightly different way.
One problem I was having had to do with how to go about looping through a list of tuples that included both parts of each tuple. I had to use a for-loop with two items (such as v and k in line 4):
Now that I had figured out this small problem in creating the for-loop, I was able to allow the user to delete each item (vocab-card) in order to take it out of the “pile”:
In this way, the user is able to work on the list until all tuples have been deleted. This isn’t an accomplishment to advanced programmers, but it’s cool to figure out these things.