August 26th, 2003, 01:38 PM
Is their a way to check, for example, in the last 2 digits in a number are 3. If so, how?
Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes!
August 26th, 2003, 02:17 PM
Well I can't think of a way to check that for ints. However, that'd be easy with strings.
Say you have received an int called someint.
Of course, change the prints for anything to your liking.
somestr = str(someint)
if somestr[-2:] == '33': print 'Yay!'
else: print 'Nay.'
Hope this answered your question. There's a mathematical way to do it, but I'm not too sure about the efficiency of my method, so I'll stick to that string method.
August 26th, 2003, 02:52 PM
OK, I'll try that.
August 26th, 2003, 03:55 PM
The simplest way to check an integer is to use the modulus operator (%).
x = 45233
if x % 100 == 33: print 'yep'