I've written a script that gets n bit values and put them together in a list. I need to make the result in binary. It gives me errors in every single method/function I try. I'm fairly new to Python, I would appreciate some help.
from itertools import product
arr = 0
val_x = []
val_y =[]
n = int(input('n = '))
if __name__ == "__main__":
for x in range (0, n + 1):
for y in range (0, n + 1):
if y == 0:
arr += 1
if arr == 1:
val_x.append(x)
val_y.append(x)
arr = 0
res = list(product(val_x, val_y))
print(res)
The result I get is:
n = 2
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
I need it in binary like this:
[(00, 00), (00, 01), (00, 10), (01, 00), (01, 01), (01, 10), (10, 00), (10, 01), (10, 10)]