Please help me to use python write this question thanks Writ
Please help me to use python write this question, thanks.
Write a function that takes a string as input and returns a string composed of only the odd indexes of the string.Solution
public String middle(String str) {
if ((str.length() % 2) == 0) {
//Even length
if (str.length() > 2) {
return str.substr( str.length / 2 - 1, str.length / 2 +1);
} else {
return str;
} //End if
} else {
//Odd length
return str.charAt( str.length / 2);
} //End if
} //End middle
