Answer the question
In order to leave comments, you need to log in
Is there an alternative to the join method?
Swap adjacent list elements (A[0] c A[1], A[2] c A[3], etc.). If there are an odd number of elements, then the last element remains in its place.
x = [int(i) for i in input().split()]
k = int(input())
z = []
i = 0
for elem in (x):
if i != k:
z.append(elem)
print(' '.join(z))
i+=1
x = [int(i) for i in input().split()]
num1 = 0
num2 = 1
num3 = 2
for i in range(0, len(x)):
if x[i] > num1:
num1 = x[i]
num2 = x[i]
if num2 < num3:
num3 = num2
for i in range(0, len(x)):
if x[i] == num1:
x[i] = num3
elif x[i] == num3:
x[i] = num1
print(' '.join(x))
x = [int(i) for i in input().split()]
x1 = 0
x2 = 0
for i in range (1, len(x), 2):
x1 = x[i]
x2 = x[i-1]
x[i] = x2
x[i-1] = x1
print(' '.join(x))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question