red_ratio=int(factor/red_average(pic))
    
    for pixel in pic:
        red=media.get_red(pixel)
        if red*red_ratio>=255:
            new_red=255
        elif red*red_ratio<255:
            new_red=red*red_ratio
        media.set_red(pixel,new_red)

''Adjust the pixels of that Picture so that the average red value of the
Picture is the same as the integer value provided.'''
i cant figure out why scale_red gives me 0 instead of 100

Most possibly rounding errors.
Suppose your average is for exemple 5, and you want to lower it to 3.
Red_ratio will be 0.
Set red_ratio to a float and round red*red_ratio instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.