I am having a general problem with learning python. I got through the first three lessons (syntax, functions, and control flow) just fine, and I feel like I have a very solid understanding of those. But then I hit lists, and the struggle has been real. I labored through it, and moved on to loops, hoping that some things that just didn’t click would click later. Loops apparently are tightly related to lists - at least the way codeacademy teaches it. I understood loops much better than lists, but I still find myself mashing that “show solution” button way too frequently. See, with lists, I understand all the concepts on an individual basis, so when I reworked my way through the lessons it was a cakewalk. But when the coding challenges begin is when I hit trouble. And looking at the solutions hasn’t helped either- often the solution involves something that makes me wonder how the heck I was expected to know how to do that in the first place. For example, take the middle element challenge for lists. Here is the solution:
if len(lst) % 2 == 0:
sum = lst[int(len(lst)/2)] + lst[int(len(lst)/2) - 1]
return sum / 2
This is some serious index stacking going on. I’m not sure how I was supposed to logically solve this problem coming from zero coding background. I mean, I can look at the solution and have a sense for what is going on with the code, but I never would have been able to come up with this solution on my own. I don’t think we were ever taught about converting lengths of lists to integers, for example. Surprisingly, the loops challenge code went a lot smoother for me, probably because the syntax of loops are more logical like booleans, and read in a logical thought pattern. Is it just unfamiliarity with what you can do with lists? These solutions seem to take some level of connecting dots with concepts that seem to be evading me. I even created a cheat sheet and rewrote individual concepts in my own words and even referring to that I fail to make certain connections that it feels like codeacademy expects me to make. As best I can figure out, my weak spots are list slicing and indexing, even though both concepts make perfect sense to me on a fundamental level, when it comes time to use them mixed with other code, I can’t seem to make a logical progression of thought using them. Anyhow, I’ve droned on enough, just was hoping someone could suggest anything or identify with the problems I am having. Tired of spinning my wheels and going over the lessons and studying code over and over again to no avail. Sorry for the complaining, I’m just frustrated!