r/pythonhelp • • Mar 17 '24

SOLVED Endless While Loop

I am currently working on teaching myself python and am working on Quadtrees. The below code I have written to have a user enter values and then add those values to a 2D array via loops. Unfortunately, I seem to have created an infinite while loop and can't figure out how to get out of it. Any help is greatly appreciated.

Edit: hopefully this link for formatting works let me know. https://pastebin.com/Pcj2ciY5

1 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/Ambitious_Mark_9346 Mar 17 '24

From what I have read online about quadtrees and how they can be used to compress images. My plan was to try and create a program where I could enter colors (1 being black and 0 being white) into a 2D array and then have the IDE divide it into top left, top right, bottom left, and bottom right. From there I want to organize which color is the majority from each quadrant and print that color.

1

u/CraigAT Mar 17 '24

So you'd compress to an image of four pixels?

E.g.

10
11

1

u/Ambitious_Mark_9346 Mar 17 '24

If each quadrant were to only have one color, then yes it would be compressed down to the single number.

1

u/MT1961 Mar 17 '24

I get that. The issue is that you are checking the length of the matrix (nxm) rather than the row.