User Profile

Collapse

Profile Sidebar

Collapse
DRKT
DRKT
Last Activity: Jun 13 '16, 03:18 PM
Joined: Jun 6 '16
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DRKT
    replied to Convert a list "of positions" into a string
    The above "simple replacement does almost the right thing but
    1st: it gives n results for n positions
    result of above code is:
    ['0', '1', '0', '0', '0', '0', '0', '0']
    ['0', '1', '0', '1', '0', '0', '0', '0']
    ['0', '1', '0', '1', '0', '1', '0', '0']
    and 2nd:
    it prints out a list not a string!

    I would need to have a single result string like this:
    "01010100"
    See more | Go to post

    Leave a comment:


  • DRKT
    replied to Convert a list "of positions" into a string
    P.S. I am using python 3.5
    See more | Go to post

    Leave a comment:


  • DRKT
    started a topic Convert a list "of positions" into a string

    Convert a list "of positions" into a string

    Hello everybody,

    I managed to convert a string of a given lenght consisting of 2 numbers only (0 and 1) into a list of positions of the number '1', (see example below).
    Note: The string size is always going to be a multiple of 4!

    Example for string lenght equals 8:
    >>> string = "01010100"
    >>> [i for i in range(len(strin g)) if string.startswi th('1', i)]
    [1, 3, 5]...
    See more | Go to post
No activity results to display
Show More
Working...