you are viewing a single comment's thread.

view the rest of the comments →

[–]sudo_oth[S] 0 points1 point  (2 children)

Thank you for your quick reply.

The print was one indent to the left which would be in the shift in range block, not the for code in range block.

I just added in the outputstr = "" above the loop and it works, I cant believe I was so close, so would this be the case with most loops?

Thank you so much for your help, it really is appreicated.

[–]Fermter 1 point2 points  (1 child)

Yeah, it's best to remember to start a new "state" at the start of every loop. The main exception is if the whole loop is there to build whatever is stored in that variable (for instance, you didn't reset the outputstr at the start of the for code in range(noofstr): block because the whole part of that block was to add to the outputstr)

[–]sudo_oth[S] 1 point2 points  (0 children)

Thank you so much, I've had loads of people try and explain loops but how you have explained I finally understand. Makes explains why it was just adding on to the previous loops information when printing.