#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    19
    Rep Power
    0

    Need help with string


    Hi,
    I use Python 2.7

    How can I take out the numbers to work with?

    I used a code that I have found on the internet.
    print ' '.join( [ '%s' % ( int( r * 60 ) ) for r in net.update( [ 1, ] ) ] )
    this gives me 6 numbers like this
    2 1 7 30 39 51
    But I don't want that.

    Then I did
    x=[ '%s' % ( int( r * 60 ) ) for r in net.update( [ 1, ] ) ]
    print x
    this gives me 6 numbers like this
    ['2', '1', '7', '30', '39', '51']
    I don't want that.

    I want
    number1=2
    number2=1
    number3=7
    number4=30
    number5=39
    number6=51
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    Unlikely, but possible that different variables are better than the list. Whatever. You might want tuple assignment.
    Code:
    (number1,number2,number3,number4,number5,number6,) = [2 ,1 ,7 ,30,39,51,]
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    19
    Rep Power
    0
    Hi ,It's a number generator that generates different numbers.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    19
    Rep Power
    0
    This is working.Thank you
    (number1,number2,number3,number4,number5,number6,) = x

IMN logo majestic logo threadwatch logo seochat tools logo