Question: Write a function that takes a single string input parameter and returns a string containing the front half of the string If the string has


Write a function that takes a single string input parameter and returns a string containing the front half of the string If the string has an odd number of characters, do not include the extra character. Your solution should also work if given an empty string. In this case, the output should also be an empty string. Examples: front_half('abba') should return 'ab' front_half('abcba') should return 'ab' 1 def front_half(s): 2 # write your code here 3 4 return 5 6 if __name _main__': 7 # you can use this to test your code 8 print(front_half('abba'))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
