How do I need to think about solving challenges?

Yeah but I can find Python forum on Reddit or other sites, without paying almost 10% of my salary for it. Codecademy as it is right now is just not for me.
Maybe I’ll come back when I’m ready for machine learning course but now I feel like it’s teaching me syntax but not what to do with it which is so frustrating that every once in a while I need some coding motivational video just to keep me wanting to learn code.

How do you use pythontutor? Whatever I paste in code editor I get just one step which doesn’t seem right. It just shows me that I am defining a function and that’s it, no way to see how it executes the code.

I would experiment with it a bit. Put a solution that codecademy gives and see what it does with that for example. I have had it give me just a single step when I put in several lines of code. Putting the return in a function at wrong indent level may have been the cause. It doesn’t always give me clues, but I think it is a good tool for learning.

1 Like

After if condition you write an else condition to return the sum, because your code is valid for the below conditions

  1. If sum is greater than 9000
  2. If list is empty

You did not write code for the the condition what should be return if sum is less than 9000

You can change the code as follows

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

If the list is empty, it will return sum as zero.

hey. i tried your code, and it didn’t work for me. what am i doing wrong?

this is my code:

def over_nine_thousand(lst):
  lst_sum = 0
  for i in lst:
    lst_sum += i
    if lst_sum > 9000:
      return lst_sum
      break
    else:
      return lst_sum

never mind. i figured it out. thanks.

You right @levyrigor!! I can’t click NEXT until i read all community forum questions below the instructions!! They are very helpful, for exemple, in this one i just got familiar with the “Visualize your code” web app and “Automate boring stuff with Python” book! I also save some comments to bookmarks…

…once i read… “If it doesn’t challenge you, it won’t change you!” Challenge is change, and change to better hopefully!

Just keep coding @refined_silver!!! and reading forums!!

Me the same,when you think like this, I think it’s the good time to pause and take a look back. What I did is :
Return back to the lesson, take note in an easiest way so you can look easier when you need ( like : how to use, when to use…). As simple as possible.
Try again every single concept that you need help before. If you still can’t solve it without hint, that could be the the missing piece you need. Take a look in forum, try to understand it. Take a break, solve it again the next day and so on, as soon as you get familiar with it.
Trust me I always use my notebook when I solve the new concepts, just look through every lesson to see what I can use and try it. Later I get used to and look no more.
More important than anything: Don’t give up and Keep moving forward!
Hope it can help.

i solve it this way:

def over_nine_thousand(lst):
suma=0
for ix in lst:
suma+=ix
if suma > 9000:
break
elif len(lst)==0:
return 0
return suma