Question: #Python please!!! Write a function `middle_character(string)` that - prints the middle character(s) of the string. -if the string length is odd, there's only one middle
#Python please!!!
Write a function `middle_character(string)` that
- prints the middle character(s) of the string.
-if the string length is odd, there's only one middle character. For example, the middle character of "123" is '2';
-if the string length is even, there will be two middle characters. For example, the middle characters of "abcd" are "bc";
For example:
| Test | Result |
|---|---|
middle_character('123') | 2 |
middle_character('abcd') | bc |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
