-3

In python2, if you did

n = 12
n /= 10

n would become 1.

In python 2, the above would cause n to be 1.2, even if it were passed in an integer parameter like

def foo(self, n: int) -> bool:
        print (n / 10)
        return True

The simple fix is to just cast it to an integer like so:

n = int(n/10)

But this is quite memory/time costly. Are there better alternatives in python3?

1 Answers1

0

// is integer division, so it removes the decimal from the result.