Hey, I just started programming but im stuck. so lets say I have a wordlist with words containing 2-12 letters and I want to remove all words containing less than 3 letters or more than 7 letters. How would i do that?

Another problem I have is, I want to find all words that contain for example these letters "negi" (it should return engine, engineer and alot of other words) , I know how to make it find all words if it is typed "engi" but not if its typed like "negi".

I can help you with first problem.
You have to show some effort,some just post there school task here.
That means that you have to post some code of what you are struggling with.

>>> s = 'a fine day with beautiful sun'
>>> l = s.split()
>>> l
['a', 'fine', 'day', 'with', 'beautiful', 'sun']
>>> [i for i in l if len(i) >= 3 and len(i) <=7]
['fine', 'day', 'with', 'sun']
>>> #Or better
>>> [i for i in l if 3 <=  len(i) <= 7]
['fine', 'day', 'with', 'sun']

Here i use list comprehension this is ofen used in python.
If you dont understand it,try to break it up with a ordinary loop.

For the second problem, you can use re.search, with a fairly simple regex. Something like this should do: [engi]{4}

That will match a lot of words that don't have ALL four of those letters though. You can probably refine it form there if needed.

This article has been dead for over six months. Start a new discussion instead.