How do I need to think about solving challenges?

Hello Everyone,

Its been three months of learning Python, spending hours at a time on the Codecademy’s site and I seem to be still lost as to how to best answer these coding challenges without having to click the solution button.

Moreover, is it my imagination or does it seem as though each challenge question may have parts of things that were previously taught, but the series of steps to solve each new problem vary to the point where every new method requires a different set of steps to solve. And I still don’t feel confident to answer any Python related questions in a forum setting.

It feels like I’m supposed to connect the dots but the dots aren’t on the page. It’s a little discouraging because I’m starting to feel incompetent. I know what for loops are, what is a while loop, and I understand most of the syntax when it is explained in the hints section or after I see it in the solution, but perhaps I’m missing some sort of creative element in figuring out how to solve these challenge questions.

I would like to know how others are able to solve these challenge questions or is everyone else racking their brain and revisiting past assignments in the hopes that something will jump out and make sense.

As a side note: Can anyone tell me if once we complete the codecademy course, are we in a position to begin seeking employment, or is this only a hobby level of skills.

Any response welcomed and thanks.

13 Likes

Can you solve the problems manually?
If so, you’ve already got the steps figured out.

1 Like

If “solve the problems manually” means knowing what to write in the answers, I follow whatever instructions that are left in the ‘Get a hint’ sections of the course. I have been able to solve the most simplest of problems but ones like this one in discussion, I NEVER would have deduced what to do on my own.

This is an example of a problem that I did not know how to approach, until I clicked the Solution button.

def larger_sum(lst1, lst2):
sum1 = 0
sum2 = 0
for number in lst1:
sum1 += number
for number in lst2:
sum2 += number
if sum1 >= sum2:
return lst1
else:
return lst2

To me, the situation is like this: We all know how to operate a drill, an electrical saw, a hammer, screwdriver, and a wrench. Now, does that mean we have the knowledge to build a house, or a car, even with all of the materials included? After the foundation (in the case of programming, the def statement, followed by the parentheses and arguments) What comes next and when?

So I have all of the tools but none of the skills/experience as to when to apply which tool or when to use several tools in combination. As I asked earlier, how is everyone else able to solve the challenge problems if they have had no prior knowledge of programming?

Again, any response welcomed. Thanks.

4 Likes

It means, given pen and paper, and the input, could you produce the looked-for output?
Or in your head for that matter.

You carry out a bunch of steps to do that.

A programming language provides ways for you to shuffle information around, same as what you did yourself.
So, what were the steps? Maybe you’d start by writing them down. You may need to break them down into smaller parts, ones that you know how to do in python.

I think you’ll find that if you put words to how the problems can be solved, that’ll be quite close to what you’d write in python.
There’s no human reading those words, you have to spell everything out in full detail.

If there’s some part of what you wrote that you don’t know how to express then you’re already a good way to finding it out, because at that point you’ve identified what information you need. It can probably be googled!

Arguably we all have a life-long experience of this information-wrangling.

7 Likes

Hello @refined_silver,

I wanted to mention that I feel in a similar way as you do, however I am not giving up. I have been making a lot of notes from previous lessons, so it is easier to review previous concepts when I am stuck since I have my notes organized (note that every person learns differently - for someone note taking is useful, someone organizes their thoughts on spreadsheet, someone does not need all that because they have great “mental storage” capabilities - so you need to find what is your best way).

Main thing I think is not to look at the answers and hints right away until you absolutely exhausted all of your knowledge and ideas. Try tweaking your code, understand what program will be doing with this code before hitting that run button - that way you know what to anticipate and you train your brain to think in the way Python thinks when it sees your code. That way you train your brain to think and find solutions rather than finding easy way by clicking on hints/answers (remember - in real world, there won’t be any hints/answers). Then, when you do review correct answers/hints, it all sounds more like “Aha” moments rather than as another disappointment because you still do not get why their solution works and your’s does not.

To answer your side note, I doubt that you can seek for employment just from completing courses here. For actual employment, we need far more advanced skills and a lot pf practice. I would suggest that these courses here are intended to introduce you with necessary knowledge and skills needed to enter into advanced type of classes, which they do a great job since other platforms seem to be lacking that expertise at helping a novice to enter this new coding world. By more advanced classes I mean bootcamps or intensive courses that are available here where you really get equipped with necessary tools a programmer needs.

Hope this helps!

6 Likes

Yes, it’s difficult. Personally, I use pythontutor.com to visualize the “processing” of my code. I recommend also “Automate the boring stuff with python” pdf or video are great !

Hi everybody,

I tried these lines first:

def over_nine_thousand(lst):
  sum = 0
  for num in lst:
      sum += num
      if sum > 9000:
          return sum
          break
      elif lst == []:
          return 0

My question is: how to introduce sum <9000 because it stops every time the loop. May be some indentation solution? An idea?

Thanks

If you it makes you feel any better, I feel the same way about this particular coding challenge section in loops. I not had any similar problems in previous Codeacademy Python training, SQL nor Numpy.
Now this may be partly because I have no previous coding experience or because I sometimes have to spend a few days away to deal with other pieces of life and partly on Codeacademy’s weak areas in training. Probably is a combination of all above.
I do like to fill in SoloLearn app on my phone for internalizing basic concepts in Python. They teach in a different order and helps me to integrate the concepts.

I also have a question about solving these, alot of the time I know how to solve it when I think of in my head, but when it comes to writing it in code I never really know how to start. I have a pretty solid understanding of the concepts, it’s just that I struggle working on how to turn my thoughts into code.

Honestly, I felt like you at this point. I then returned back to the explanation unit!

I just gotta add something since I’ve been reading many people complaining about how Codecademy lessons never covered sum() or max() functions and so on. So I’ll try and make my reply here as short as I can, but informative and encouraging for anyone who never had experience coding, just like me :slight_smile:
If you feel like the lessons haven’t covered Python functions, you haven’t been paying attention! There’s a reason why every lesson has a link to Codecademy forums at the bottom. And after finishing a lesson I’ve NEVER moved on to the next lesson without checking the linked subject on the forum first. I read through everything and take notes. Don’t skip and don’t try to make this journey easier.
And ■■■■ yeah, the challenges are not easy for begginers. But again, they are called “challenge” for a reason, don’t you think? And they certainly live up to their name… on some of these I’ve spent days. Until I’ve run out of every possible combination my brain could think of, until I’ve completely run out of will and motivation to keep solving the problem, only then I’d check the solution. It happened three times so far. BUT I would never just leave after that. I would write down the entire problem so I can always return to it cause my brain will probably slip on a similar problem again in future and then I would study the code line by line until I’m 100% sure I understand every piece of it and what I was doing wrong.
Be resourceful just like you would in school or college, check everything Codecademy offers, google if need be but be sure to understand the process and what every piece of code does. It’s perfectly ok to be stuck on a problem and it’s ok to fail sometimes. As long as you learn from all of it, it can only benefit you.
Cheers Everyone and good luck :slight_smile:

2 Likes

The main issue I have had with the exercises would seem to be more of a bug. My solutions return what the exercise is asking; however, I then get error messages saying I supposedly do not have the correct answer when the console is showing I do. I do have a lot of prior experience with software development. Though a majority of my experience to this point has be with C#, VB .NET, Java, T-SQL, MySQL, and a few other things I learned during my associates and then bachelor’s degree programs.

Keep up the work. learning to code can take time; if you ever seem overwhelmed, the best thing to do is just get up and walk away for a bit. Also, creating pseudo-code which someone has referenced would help. Also, Google is always a great place to go for answers.

Ian, if you kept with it, I hope Python got a bit easier to understand :slight_smile:

I was thinking in the order, first validating if the list is empty or not, then the first statement validating if its less than 9000, and last the break to stop the loop

#Write your function here
def over_nine_thousand(lst):
  sum = 0
  if len(lst) == 0:
    return 0
  for i in lst:
    sum += i
    if sum < 9000:
      print("this is lower")
    elif sum > 9000:
      break
  return sum

#Uncomment the line below when your function is done
print(over_nine_thousand([8000, 900])) # change the values for testing 

I feel the same most of the time. Just knowing that I still have few more code challenges to go made me don’t want to show up in Codecademy, and I dread those challenges even more each day. The solutions and other people’s code really made sense when I see them, but I cannot articulate the solution using Python from scratch. It feels like I know it should go like that, but I don’t know how to translate it into codes, Sometimes I passed the challenges, but not in the way they want me to do it (use loops, etc.).

In my unfortunate days, the cycle usually goes like this: tried to code without using hint, then got an error. I looked at the hint, it made me way more confused, tried to follow it anyway and still got an error. I always opened the forum, then got lost in the posts, tried few solutions that made sense to me, which usually works. If everything in the forum does not make any sense to me at all, I finally hit that View Solution button, which is often. Next, I embrace all the sadness, frustrated, demotivated and defeated feelings while taking notes of the solutions (I put them inside a private repo in my GitHub account, just to get myself used to GitHub) and go back to the lessons and find other resources to make sure I understand it. For now, it is clear that I need more exercises on lists and loops.

Even so, here I am keep going through all the lessons and challenges. It’s definitely not easy, but I think it’s worth it. I’m sure there are many people who feel discouraged but decided to keep going, and it’s a good thing to do.

1 Like

Code someone review my code and tell me whether I did it correctly or if I missed the mark? Either way it seems to satisfy all three cases, and I am allowed to progress. I guess I’m surprised because it just seems so simple.

#Write your function here
def over_nine_thousand(lst):
  sum1 = 0 
  for num in lst:
    if sum1 < 9000:
      sum1 += num
  return sum1 

#Uncomment the line below when your function is done
print(over_nine_thousand([]))
#print(over_nine_thousand([8000, 900, 120, 5000]))

over != at least

try to match your code semantically to what the requirement is. it should do that

so if it says over, then you really need to test “is it more than 9000? if so, stop”, you’re doing something slightly different, it doesn’t semantically match

and it says “stop”, but your loop will continue, so that doesn’t match

Ok, so what is the question asking me, because it is a bit obtuse? From what I understood, and from the desired result of the provided code, it seems that you just keep adding the next element in the list until the sum is over 9000.

Is it that I am supposed to check all the elements, and determine which elements I can add until it hits 9000?

Argh I’m just even more confused, especially since I am allowed to progress with the code I created.

that’s accurate.
your code does not do that.

wildly inadequate tests

you are doing things that are similar. a human might say it’s close enough.
but it’s different
it doesn’t do the thing promised

so your options are to either ensure it is equivalent (harder)
or do the thing the function description says (easier)

If the description says over 9000, then you’d want to test for over 9000, not less than 9000. Yeah there’s something equivalent you can do there, but now you’ve created a new problem, you have to ensure it’s equivalent. If you test for the same thing, that’s one problem less, therefore that is easier to get right.

The stopping mechanic is also something where you do something that might be made equivalent, but it continues to do things after the condition result has changed, is that equivalent? If you brought it to a stop, you’d be doing the same thing as the description says and you wouldn’t need to worry about whether it’s equivalent.

I second the pythontutor.com suggestion as a way to find clues. It is a little frustrating and I am pretty sure some techniques were not taught in lessons, despite other postings to the contrary. Maybe I should be checking every link in every lesson, but not all are relevant and they take time to review.
I find these challenges daunting at times because I am learning what I don’t know, but checking forum posts on challenges and googling and trying code in python tutor are part of the learning process, I guess.