Question: Write a simple program using string operations to create three new strings from a given string. (a) The newly created string should swap the
Write a simple program using string operations to create three new strings from a given string. (a) The newly created string should swap the first and last characters and keep all the other characters as is. The program should ensure that only the first character is in the uppercase if it is an alphabet. For example, if the input is "Lineman" the output should be "ninemal". (b) The newly created string should reverse the order of only the characters in the middle leaving the first and last characters as is. For example, if the input is "Lineman" the output should be "Lamenin". (c) The newly created string should reverse the second half of the string leaving the first half as is. For strings with odd number of characters, include the middle character in the econd half. For example, if the input is "Lineman" the output should be "Linname".
Step by Step Solution
3.43 Rating (150 Votes )
There are 3 Steps involved in it
23 2 mainpy 1 def modifystringinputstr a Swap the first and last characters keeping other char... View full answer
Get step-by-step solutions from verified subject matter experts
