So i have list contains with 1 string.
biner_pass = ['00001111000000000000111111111111
00001111111111111111000011111111 11111111111100000000000000000000
11111111111111110000111111111111']
all i want is to remove the space and join all the binary.
i was trying using
binerpass = ''.join(biner_pass.split(' '))
or biner_pass.replace(" ", "")
but it cannot work. so how to remove space?
CodePudding user response:
The string is the 0-th element of a list with 1 element. Therefore you need
biner_pass[0].replace(" ", "")
CodePudding user response:
IIUC, You can use replace
.
biner_pass = ['0000111100000000000011111111111100001111111111111111000011111111 1111111111110000000000000000000011111111111111110000111111111111']
biner_pass[0] = biner_pass[0].replace(" ", "")
print(biner_pass)
Output:
['00001111000000000000111111111111000011111111111111110000111111111111111111110000000000000000000011111111111111110000111111111111']
CodePudding user response:
You need to do it for each element of the list
biner_pass = [b.replace(' ','') for b in biner_pass]
CodePudding user response:
binary
will be a string that conatains 1
and 0
without spaces
binary = "".join(biner_pass).replace(" ", "")