python - nested defs not working -


what need add second def statement in order work?

def main():     # user has choose picture , asked     pic = makepicture(pickafile())      # user asked select color wants remove picture     color = requeststring("which color remove?")     show(pic)      # whats wrong last part doesn't make modifications picture     def removecolor(pic, color):         r = red         g = green         b = blue         px in getpixels(pic):             setred(px, 0)          px in getpixels(pic):             setgreen(px, 0)          px in getpixels(pic):             setblue(px, 0)      repaint(pic) 

here take out removecolor function main function, , call inside main

def removecolor(pic, color):     r = red     g = green     b = blue     px in getpixels(pic):         setred(px, 0)      px in getpixels(pic):         setgreen(px, 0)      px in getpixels(pic):         setblue(px, 0)  def main():     # user has choose picture , asked     pic = makepicture(pickafile())      # user asked select color wants remove picture     color = requeststring("which color remove?")     show(pic)      removecolor(pic, color) # here i'm calling removecolor     repaint(pic) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -