Dcoder icon

Please check the password! @ Dcoder

By Lochard | As a newbie programmer | 17 Aug 2023


Problem: Ethan has a possible list of password to hack a secure account. To select the correct password, he researched the owner and discovered that the account's owner is very fond of acronyms. After eliminating the rest of the patterns, Ethan is now sure that the password and its reverse, both, are present in the list. You need to find the password among that list and print its length along with its middlemost character.

NOTE: All strings in the list are of odd length.

Input: First line contains N, the number of elements in the list.

The next N lines each contain a single word.

Output: Print the length of the password and its middlemost character separated by a string.

Constraints: 1 ≤ N ≤ 50

1 ≤ string.length ≤ 20

Sample Input: 4

xyz

dco

der

zyx

Sample Output: 

3 y

lst = []
for t in range(int(input())):
  lst.append(input())
for password in lst:
  if password[::-1] in lst:
    print(len(password), password[len(password)//2])
    break

How do you rate this article?

2


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.