Task2: Swap Adjacent List Elements Input two or more chars separated by spaces: a b a ba ba b Initial list ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'] String version: 'abababab' Modified list Example of...


Python code


Task2: Swap Adjacent List Elements<br>Input two or more chars separated by spaces: a b a ba ba b<br>Initial list<br>['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b']<br>String version: 'abababab'<br>Modified list<br>Example of case 1 (even # of items)<br>['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a']*<br>String version: 'babababa'<br>--- Task2: Swap Adjacent List Elements<br>---- --<br>Input two or more chars separated by spaces: t hi sis atest<br>Initial list<br>['t', 'h', 'i', 's', 'i', 's', 'a', 't', 'e', 's', 't']<br>String version: 'thisisatest'<br>Modified list<br>Example of case 2 (odd # of items)<br>['h', 't', 's', 'i', 's', 'i', 't', 'a', 's', 'e', 't']<br>String version: 'htsisitaset'<br>Task2: Swap Adjacent List Elements<br>Input two or more chars separated by spaces: 1 2 3 4 5<br>--- ---<br>Initial list<br>['1', '2', '3', '4', '5']<br>String version: '12345'<br>Modified list<br>['2', '1', '4', '3', '5']<br>String version: '21435'<br>Task2: Swap Adjacent List Elements<br>Example of that causes an<br>Input two or more chars separated by spaces: 1<br>Traceback (most recent call last):<br>File
main() File "final.py", line 110, in main task2() File "final.py", line 65, in task2 assert n >= 2, "Must enter two or more characters!" AssertionError AssertionError: Must enter two or more characters! "/>
Extracted text: Task2: Swap Adjacent List Elements Input two or more chars separated by spaces: a b a ba ba b Initial list ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'] String version: 'abababab' Modified list Example of case 1 (even # of items) ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a']* String version: 'babababa' --- Task2: Swap Adjacent List Elements ---- -- Input two or more chars separated by spaces: t hi sis atest Initial list ['t', 'h', 'i', 's', 'i', 's', 'a', 't', 'e', 's', 't'] String version: 'thisisatest' Modified list Example of case 2 (odd # of items) ['h', 't', 's', 'i', 's', 'i', 't', 'a', 's', 'e', 't'] String version: 'htsisitaset' Task2: Swap Adjacent List Elements Input two or more chars separated by spaces: 1 2 3 4 5 --- --- Initial list ['1', '2', '3', '4', '5'] String version: '12345' Modified list ['2', '1', '4', '3', '5'] String version: '21435' Task2: Swap Adjacent List Elements Example of that causes an Input two or more chars separated by spaces: 1 Traceback (most recent call last): File "file.py", line 119, in main() File "final.py", line 110, in main task2() File "final.py", line 65, in task2 assert n >= 2, "Must enter two or more characters!" AssertionError AssertionError: Must enter two or more characters!

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here