Whats the best way to round an odd number to an even one?

Use // floor division instead if you don't like relying on the Python 2 / behaviour for integer operands:

rounded_val = (len(src_string) // 2) * 2

Maybe

rounded_val = len(src_string) & ~1

This simply clears the 1s bit, which is exactly what you need. Only works for ints, but len should always be integer.


How about this:

rounded_val = len(src_string) & (-2)

Although it is sometimes not obvious to someone not familiar with binary arithmetic.