I want to print modulus operator as it is over the command line:
E.g this is how the output should look like:
1%2
2%4
or
30%
40%
I am using the print statement like this:
print 'computing %s % %s' % (num1, num2)
Its throwing the default error:
TypeError: not all arguments converted during string formatting
For now I am using:
print 'computing 1'+'%'+'2'
which prints:
computing 1%2
But tell me how to get this done using the first approach(:print 'computing %s % %s' % (num1,num2))
Escape the % sign with another % sign, like this:
print 'computing %s %% %s' % (num1, num2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With