Please help make a function swaphalvess that takes a string


Please help make a function swap_halves(s) that takes a string input s and returns a string whose first half is s's second half and whose second half is s's first half. If Len(s) (the length of s) is odd, the first half of the input string should have one fewer character than the second half, and thus the second half of the output string will be one character shorter in such cases. For example:

>>> swap_halves('homework')
'workhome'
>>> print(swap_halves('carpets'))
petscar

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Please help make a function swaphalvess that takes a string
Reference No:- TGS02651600

Now Priced at $10 (50% Discount)

Recommended (98%)

Rated (4.3/5)