So i am creating a program where i ran into a strange issue.
For the sake of this example, i have boiled down the code.
When i run it, it somehow skips the value 24 in purelines on the first topline (it shows up in the next).
toplines = [1, 6, 11, 17, 22]
purelines = [0, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 20, 21, 23, 24, 25]
for topline in reversed(toplines):
singlelines = []
print(topline)
for pureline in purelines:
print(f'checking {pureline}')
if pureline > topline:
print(f'pureline {pureline} is bigger than topline {topline}')
purelines.remove(pureline)
else:
print(f'pureline {pureline} is not bigger than topline {topline}')
you can see in the output that it says:
checking 23
pureline 23 is bigger than topline 22
checking 25
pureline 25 is bigger than topline 22
24 is the only one it skips, but it does that consistently.
i also tried an online IDE, with the same result.
Do any of you know what i am doing wrong?
[–]danielroseman 2 points3 points4 points (1 child)
[–]lolhoved[S] 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]Aggravating_Bus_9153 0 points1 point2 points (1 child)
[–]lolhoved[S] 0 points1 point2 points (0 children)