Closed purisusmita closed 4 years ago
You are appending a statement (i % 27 ==0), instead of the current number, i. This results in a list of trues, due to the if-statement in the line prior :-)
thanks, I tried changing the code and answer_024=[] i=0 for i in range(1000): answer_024.append(i%27) print (answer_024) it still doesn't assert.
The exercise asks you to append the number i. If i is a multiple of 27 (i%27==0), then the number i should be appended. You still need an if statement as in the code before the change :-) Another problem can be the loop. You are using a for loop instead of a while loop. Remember that i=1000 should not be included and to increment i in the while loop (i += 1) :-)
So the loop should look approximately like this:
while (i<1000): if i%27==0: #check if i is a multiple of 27. If true, append i answer_024.append(i) i += 1
i = 0 answer_024 = [] for i in range(1000): if i % 27==0: answer_024.append(i % 27== 0) print (answer_024)
why does this keep sowing lots of true in output? How do we solve this part?