electronut / pp

Code for book Python Playground by Mahesh Venkitachalam (No Starch Press, USA)
568 stars 501 forks source link

code error #16

Open caiyingchun opened 6 years ago

caiyingchun commented 6 years ago

In project photomosaic.py, in line 180:

if not reuse_images: 
    input_images.remove(match)

I wonder variable ‘match' is miswritten. it is never defined in codes. But I don't know what it should be replaced?

Co5moDr0ne17 commented 6 years ago

I just finished working through the photomosaic tutorial the other day. This is how I altered the code to account for the 'match' and it seems to work fine.

if not reuse_images: input_images.remove(input_images[match_index]) avgs.remove(avgs[match_index])

*Once you remove the image that is stored at match_index you have to also remove its average rbg value too otherwise you'll get an error.

caiyingchun commented 6 years ago

Thank you very much! It works!