Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(n):
- res = []
- k = 1
- for r in range(n):
- row = []
- for c in range(n):
- row.append(k)
- k += 1
- if r % 2 != 0:
- res.append(row[::-1])
- else:
- res.append(row)
- return res
- a = f(5)
- for x in a:
- print(x)
Advertisement
Add Comment
Please, Sign In to add comment