I was looking for a program to do the elfish instances. Then I found this javascript code on the web.
var containsE;
var containsL;
var containsF;
function elfish(str){
var checkLetter = str[str.length - 1];
if (checkLetter === "e"){
containsE = true;
}
else if (checkLetter === "l"){
containsL = true;
}
else if (checkLetter === "f"){
containsF = true;
}
// base case
if (str.length === 0)
if (containsE && containsL && containsF){
return true;
}
else {
return false;
}
// if not base case
return elfish(str.slice(0, str.length - 1));
}
elfish("whiteleaf");
I wonder if it is possible to guide me to convert the code into python with an explanation? the python version is 2.73