Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subscripting Integers?
#1
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?
Reply
#2
(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)
[Image: izsyo6.jpg]


Reply
#3
Code:
Number = 929302.023
if str(Number)[1] == "2": print "Second number is 2"
[Image: nv70ad.png]
Terrorcore, unleash, extermination
Hyper real, cold blood, determination
fudge them, I like this sensation
Incredible, I from the annihilation
Reply
#4
(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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)