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))
x = map(int, input().split())
for i, j in enumerate(x):
if i % 2:
x[i], x[i-1] = x[i-1], x[i]
print(' '.join(map(str, x)))
x = list(map(int, input().split()))
mi, ma = min(x), max(x)
i, j = x.index(mi), x.index(ma)
x[i], x[j] = ma, mi
print(' '.join(map(str, x)))
Условие то же, что и в первом?
from itertools import chain, zip_longest
def mix(sequence, fltr=lambda e: e is not None):
return filter(fltr, chain(*zip_longest(sequence[1::2], sequence[0::2], fillvalue=None)))
print(''.join(mix('12345678'))) # => '21436587'
print(''.join(map(str, mix([1, 2, 3, 4, 5, 6, 7, 8, 9])))) # => '214365879'
print(list(mix([1, 2, 3, 4, 5, 6, 7, 8, 9]))) # => [2, 1, 4, 3, 6, 5, 8, 7, 9]
from operator import itemgetter
def swap(sequence, keyfunc=itemgetter(1)):
min_value_index, min_value = min(enumerate(sequence), key=keyfunc)
max_value_index, max_value = max(enumerate(sequence), key=keyfunc)
sequence[min_value_index], sequence[max_value_index] = max_value, min_value
return sequence
print(swap([3, 4, 0, 7, 1, 9, 8, 6, 2, 5])) # => [3, 4, 9, 7, 1, 0, 8, 6, 2, 5]