Python | Kth index character similar Strings

Sometimes, we require to get the words that have Kth index with the specific letter. This kind of use case is quiet common in the places of common programming projects or competitive programming. Let’s discuss certain shorthand to deal with this problem in Python.

Method #1 : Using list comprehension + lower()
This problem can be solved using the combination of above two functions, list comprehension performs the task of extending the logic to whole list and lower function checks for case insensitivity with the target word of argument letter.





# Python3 code to demonstrate
# Kth index character similar Strings
# using list comprehension + lower()
# initializing list
test_list = ['Akash', 'Nikhil', 'Manjeet', 'akshat']
# initializing check letter
check = 'k'
# initializing K 
K = 2
# printing original list
print("The original list : " + str(test_list))
# using list comprehension + lower()
# Kth index character similar Strings
res = [idx for idx in test_list if idx[K - 1].lower() == check.lower()]
# print result
print("The list of matching Kth letter : " + str(res))


Output :

The original list : ['Akash', 'Nikhil', 'Manjeet', 'akshat']
The list of matching Kth letter : ['Akash', 'akshat']


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.