psy4 part b. how do you create a while loop that runs until it reaches the last item in a list? i'm trying to run through the second problem in problem set 4 and need to create a condition for looping through the list of growth rates. am i thinking about this correctly or is there a better set of criteria for the while loop? here's my code so far: http://dpaste.com/546068/
I used a for loop instead of a while loop like this: for year in range(1,len(growthRates)+1): that will get the length of the growthRates list and I add one more to include the last element. Hope that helps!
I used a for loop too. If you really want to use while you can use while(i<len(glist)) (where glist is the list you want to run through. Then use glist[i] within the loop to use each element (if you want too). However, for loop is the easiest way to go.
Join our real-time social learning platform and learn together with your friends!