Support Forums

Full Version: Subscripting Integers?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I do something like this:

Code:
x = 29
if x[1] == 9:
    print "The second digit is 9"
else:
    print "The second digit is not 9"

However I can't do this because you can't subscript integers. How can I get around that?
(02-18-2010, 09:17 PM)nevets04 Wrote: [ -> ]How can I do something like this:

Code:
x = 29
if x[1] == 9:
    print "The second digit is 9"
else:
    print "The second digit is not 9"

However I can't do this because you can't subscript integers. How can I get around that?

Cmon Nevets, convert it
Code:
str(29)
Code:
Number = 929302.023
if str(Number)[1] == "2": print "Second number is 2"
(02-18-2010, 09:20 PM)uber1337 Wrote: [ -> ]Cmon Nevets, convert it
Code:
str(29)

Lol, I feel dumb. It's been a while Big Grin