Hi, this does compile but I only want results that have the same amount of characters as the input! Can anyone shed some light on this as I can't figure it out myself! thanks.

import re

# opens a .txt file and searches for matching letters in words that are same length as the input!

file = open("words.txt","r")
text = file.readlines()

name = input("enter your name: ")

keyword = re.compile(r"[name]")

for i in text:
if keyword.search(i):


Recommended Answers

All 3 Replies

wow! this looks to be very useful for my solution, though my task does not require all input characters to be present in search results, as long as the results are words that are only as long as the input word and have at least one of the input characters. but thanks, I must study this further to try and understand how it all works.

p.s I'm rather new to python.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.