Suppose I have a (binary) string with length n
. My goal is to assign the values of each element of the string to n
variables: m_1, m_2, ..., m_n
. I can do that when n
is fixed: m_1, m_2, m_3 ,m_4, m_5 = map(int, '10110')
.
However, I don't know how I can do that dynamically, to accommodate an arbitrary n
. I thought about using a list comprehension, but still not sure how it works to solve this problem.