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

yii framework simple shopping cart tutorial for beginners

yii2 arrayhelper::map vs array_map