???????: Write a Python program that takes a list and a step size(integer number) as inputs from the user. Your program should swap elements from the front and back while maintaining the step size. [You are not allowed to use built-in replace() function] ================================ Sample Input 1: A,B,C,D,E,F,G,H 2 Sample Output 1: Before swap: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] After swap: ['H', 'B', 'F', 'D', 'E', 'C', 'G', 'A'] Explanation 01: Here in the input, a list is given as input, and 2 is the step size. ‘A’(index0) swaps places with ‘H’(index -1). Then step size increments by 2. 0+2= 2. Swapping starts from index2. ‘C’(index2) swaps places with ‘F’(index -3). ================================ Sample Input 2: A,B,C,D,E,F,G,H 5 Sample Output 2: Step size is not suitable Explanation 02: Here in the input, a list is given as input, and 5 is the step size which is greater than half of the list length. So swapping is not possible. ================================ Sample Input 3: A,B,C,D,E,F,G,H,I,J,K 3 Sample Output3: Before swap: ['A','B', 'C', 'D', 'E', 'F', 'G','H', 'I', 'J','K'] After swap: ['K', 'B', 'C', 'H', 'E', 'F', 'G', 'D', 'I', 'J', 'A'] Explanation 03: Here in the input, a list is given as input, and 3 is the step size. ‘A’(index0) swaps places with ‘K’(index -1). Then step size increments by 3. 0+3= 3. Swapping starts from index3. ‘D’(index3) swaps places with ‘H’(index -4).
????????:
Write a Python program that takes a list and a step size(integer number) as
inputs from the user. Your program should swap elements from the front and
back while maintaining the step size.
[You are not allowed to use built-in replace() function]
================================
Sample Input 1:
A,B,C,D,E,F,G,H
2
Sample Output 1:
Before swap: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
After swap: ['H', 'B', 'F', 'D', 'E', 'C', 'G', 'A']
Explanation 01:
Here in the input, a list is given as input, and 2 is the step size.
‘A’(index0) swaps places with ‘H’(index -1). Then step size increments by
2. 0+2= 2. Swapping starts from index2. ‘C’(index2) swaps places with
‘F’(index -3).
================================
Sample Input 2:
A,B,C,D,E,F,G,H
5
Sample Output 2:
Step size is not suitable
Explanation 02:
Here in the input, a list is given as input, and 5 is the step size which
is greater than half of the list length. So swapping is not possible.
================================
Sample Input 3:
A,B,C,D,E,F,G,H,I,J,K
3
Sample Output3:
Before swap: ['A','B', 'C', 'D', 'E', 'F', 'G','H', 'I', 'J','K']
After swap: ['K', 'B', 'C', 'H', 'E', 'F', 'G', 'D', 'I', 'J', 'A']
Explanation 03:
Here in the input, a list is given as input, and 3 is the step size.
‘A’(index0) swaps places with ‘K’(index -1). Then step size increments by
3. 0+3= 3. Swapping starts from index3. ‘D’(index3) swaps places with
‘H’(index -4).
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)