palindrome in python3.6 and php7




I am just practising, some interview question in both python and php to solve palindrome in easy way  to remember in interview.please share your solution or any latest interview question both php and python in comment box.


PHP :

$s = 'malayalam';

$y = '';

for ($i = strlen($s) - 1; $i >= 0; $i--) {

    $y .= $s[$i];
}

echo $y . '</br>';

if ($s == $y) {

    echo "true";
else {

    echo "false";
}

Python :
= 'malayalam';
b = ''
for i in a:
b = i + a
pirnt(b)
if(a == b):
print("Yes")
else:
               print('No')

Comments

Popular posts from this blog

create pdf by using javascript

Question: Why should we use class name in another class constructor function in php7?