Jun-23-2020, 03:49 PM
As you can notice, this function is designed to create binary numbers in order into a list of lists. It works for 4 digits and each for loop is responsible for modifying a certain position.
I would like to modify it so I can use it for any number of digits, but I haven't found a way to do it as I have to add a for loop every time I want to add a digit.
Thank you so much for your help.
I would like to modify it so I can use it for any number of digits, but I haven't found a way to do it as I have to add a for loop every time I want to add a digit.
Thank you so much for your help.
def Binarynum(): lista=[]; for i in range(2): for j in range(2): for k in range(2): for l in range(2): lista.append([i,j,k,l]); return lista; lista=Binarynum();