Oct-03-2017, 04:19 PM
(This post was last modified: Oct-03-2017, 04:21 PM by ichabod801.)
if you want to get the digits of a number, there are two ways to do it. One is to convert to string, pull out the digit, and convert it back to integer:
>>> x = 12345 >>> three = str(x)[2] >>> int(three) + 2 5The other way is to use the modulus operator (%) which returns the remainder after division, and integer division (//)
>>> x = 12345 >>> y = x // 100 >>> y 123 >>> three = y % 10 >>> three + 2 5
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures