- #1
shivajikobardan
- 674
- 54
I am learning to code and 1 thing that surprises me is how do I internalize all the code? I understand the code. I know the algorithm as well. But I want to be able to solve any types of problems(related ones) after learning 1 code. How do I become able to do that? So for that I am first trying with palindrome program.
Here is the palindrome program for even palindrome.
Now I want to write code for odd palindrome. Don't show me code but show me direction or algorithm so that I can write code on my own.
example of odd palindrome is abbcbba. We are using c as the middle point.
Here is the palindrome program for even palindrome.
Code:
#palindrome checking
str1="abba"
for i in range(len(str1)//2):
if(str1[i]==str1[len(str1)-i-1]):
isPalindrome=True
else:
isPalindrome=False
print(isPalindrome)
example of odd palindrome is abbcbba. We are using c as the middle point.