Round number to nearest integer
I've been trying to round long float numbers like:
32.268907563; 32.268907563; 31.2396694215; 33.6206896552; ...
With no success so far. I tried
math.floor(x) (although that would round up or down, which is not what I'm looking for) and
round(x) which didn't work either (still float numbers).
What could I do?
for i in widthRange: for j in heightRange: r, g, b = rgb_im.getpixel((i, j)) h, s, v = colorsys.rgb_to_hsv(r/255.0, g/255.0, b/255.0) h = h * 360 int(round(h)) print(h)
Will round it and change it to integer
You are not assigning int(round(h)) to any variable. When you call int(round(h)), it returns the integer number but does nothing else; you have to change that line for:
h = int(round(h))
To assign the new value to h
★ Back to homepage or read more recommendations: