In this program, I am trying to swap odd and even positions of the integers in a sequence of all positive integers. n is the size of the sequence and each integer in the sequence cannot be more than n. I have to take the value of n from the user.
note: If n (the size of the sequence) is odd, I will have to print -1.
Here's is my code:
def permu_size(n):
lst = []
if (n % 2 != 0):
print(-1)
else:
for i in range(1, n+1):
lst.append(i)
for k in range(len(lst)):
x = lst[2k]
y = lst[2k+1]
x, y = y, x
print(x, y, end=" ")
n = int(input())
permu_size(n)
In my code, I am getting SyntaxError: invalid syntax (, line 11) in line 11. But I cannot figure out what is triggering this error.