I need a function rep(n) that takes an integer and returns set of sets representing n. It must behave this way:
>>> rep(0)
[]
>>> rep(1)
[[]]
>>> rep(2)
[[], [[]]]
>>> rep(3)
[[], [[]], [[], [[]]]]
Python is new to me, so I am struggling a lot with the syntax. I am not sure how to write this function.
This is what I makes sense to me but I am sure this is nowhere near python code"
>>> rep(0)
[]
>>> rep(1)
[[]]
>>> rep(2)
[[], [[]]]
>>> rep(3)
[[], [[]], [[], [[]]]]
Python is new to me, so I am struggling a lot with the syntax. I am not sure how to write this function.
This is what I makes sense to me but I am sure this is nowhere near python code"
def rep(n): [x for x in range(n)] 0 = [] 1 = [[]] for i in range(n) return '[]' if i==0 else '[[]]' if n==1 else range(i)