What would be an easy way to convert:
(1,0,0,0,0,0)
to
['100000']
I know how to switch it to a list using
list()
but i can't figure out how to combine the elements into a string and keep that inside a list.
What would be an easy way to convert:
(1,0,0,0,0,0)
to
['100000']
I know how to switch it to a list using
list()
but i can't figure out how to combine the elements into a string and keep that inside a list.
sep.join(strlist)
joins a list of strings together using sep
as a separator.
In this case, you will have three steps:
strlist = map(str, intlist)
Convert the list of strings to a single string using join
.
intstring = "".join(strlist)
Setting the separator = ""
will make it squish together to a single string.
final = [intstring]
Or in one line, as in falsetru's comment:
[''.join(map(str, digits))]