Hello everyone
,
I have a problem with my code.
I must write a program that reads a string and from it obtain all the palindromes that can be obtained.
It must not write palindromes less than two letters and only must appear once.
The problem that I have in my code and that I cannot solve it, is that it prints the palindromes of a single character and they should not appear.
##############
###EXAMPLE:###
##############
Input: madam
Output: madam
maam
mdm
mam
mm
ada
aa
If anyone is able to define a function that allows this, I would appreciate it.
I leave the code that I have attached:

I have a problem with my code.
I must write a program that reads a string and from it obtain all the palindromes that can be obtained.
It must not write palindromes less than two letters and only must appear once.
The problem that I have in my code and that I cannot solve it, is that it prints the palindromes of a single character and they should not appear.
##############
###EXAMPLE:###
##############
Input: madam
Output: madam
maam
mdm
mam
mm
ada
aa
If anyone is able to define a function that allows this, I would appreciate it.
I leave the code that I have attached:
def find_all_subsets(seq, n): if n == 0: return [[]] else: result = [] subsets = find_all_subsets(seq, n-1) for subset in subsets: result += [subset] result += [[seq[n-1]] + subset] return result def check_palindrome(subsetsList): finalList = [] for set in subsetsList: if set[::-1] == set: finalList.append(set) else: continue return finalList if __name__ == "__main__": word = input("Write string: ") palindromicSubsets = check_palindrome(find_all_subsets(word, len(word))) print(palindromicSubsets)Thank you very much!
