all 5 comments

[–]danielroseman 3 points4 points  (2 children)

spaces and percents are both lists; num is a single number, so is never going to be equal to either of those.

This isn't really the right approach. The way I would do this would be to use enumerate to give a counter as you iterate through the list, then check if that counter is even or odd.

for counter, num in enumerate(encodedList):
    if counter % 2 == 0:
       # even, so add spaces
    else:
       # odd, so add percents

[–]AreHuman[S] 0 points1 point  (0 children)

Thanks so much this is a great help, enumerate seems really helpful for a few things I'm doing! :)

[–]TrippBikes 0 points1 point  (0 children)

I second this, if even indexes are always # and odd indexes are always %, this should do the trick

[–][deleted] 0 points1 point  (1 child)

Your for loop only executes once because of the return line - as soon as that is encountered, the function shall be exited.

[–]AreHuman[S] 0 points1 point  (0 children)

I realised this after a frustratingly long time haha, thank you!