string = list(input('Введите строку: '))
for i in range(len(string)):
if string[i] == 'а':
string[i] = 'б'
elif string[i] == 'б':
string[i] = 'а'
elif string[i] == 'А':
string[i] = 'Б'
elif string[i] == 'Б':
string[i] = 'А'
print(''.join(string))
Объяснение:
string = list(input('Введите строку: '))
for i in range(len(string)):
if string[i] == 'а':
string[i] = 'б'
elif string[i] == 'б':
string[i] = 'а'
elif string[i] == 'А':
string[i] = 'Б'
elif string[i] == 'Б':
string[i] = 'А'
print(''.join(string))
Объяснение: