I am trying to find words with letters in specific positions within my dataframe. My dataframe is a list of all 5 letter words in English in all lower-case and no special characters (i.e. only alpha characters).
df = list of 5 letter words
word = column of words
Code:
firstLetter = input('First Letter = ')
secondLetter = input('Second Letter = ')
thirdLetter = input('Third Letter = ')
fourthLetter = input('Fourth Letter = ')
fifthLetter = input('Fifth Letter = ')
total = str(firstLetter)+str(secondLetter)+str(thirdLetter)+str(fourthLetter)+str(fifthLetter)
df[df['word'].str.contains(total)]['word']
This will find all words that contain user inputed letters in the order inputed. While useful, it's not exactly what I'd like to do. How would I search for words that only contain letters in specific positions and print that list. For example:
First letter = t
Second Letter = r
Third Letter =
Fourth Letter = i
Fifth letter = n
Out: Train
I'm quite new to both python and jupyter and I would like to thank you for your help in advance.