Question: code as python coding CSc 120: List to String (Version 2) Expected Behavior Write a function concat elements2(Mist, startpos, stoppos), where list is a list
code as python coding
CSc 120: List to String (Version 2) Expected Behavior Write a function concat elements2(Mist, startpos, stoppos), where list is a list of strings and startpos and stoppos are integers, that concatenates the elements of list starting at position startpos and ending at position stoppos (inclusive) and returns the resulting string Your code should behave reasonably for all values of startpos and stoppos: if startpos is negative, concatenation should start with the first element of ist, if stoppos 2 len(list), concatenation should stop at the last element of list. If startpos> stoppos it should return the empty string. See the examples below. Programming Requirements Solve this problem without explicitly iterating over the list. One way to do this involves a combination of slicing and join() Examples 1. concat elements2('aa,'bb', 'cc', 'dd'], 1, 3) return value: bbccdd . 2.concat elements2(l'aa', 'bb',ce','aa', -,1 3. concat_elements2(1 'aa,'bb', 'cc', 'dd'1. -9, 9 4. concat-elements 2( 1 . aa' , . bb, ' . ce' , 'dd' ), 3, 3) 5 concatelements2(l'aa', 'bb', 'cc', 'dd'1, 3, 1) return value: 'aabb return value: aabbccdd return value: 'dd return value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
