0

I am confused about a simple task

the user will give me a string and my program will check if this string equals the first letters of a list of words ( like this example)

>>> html_attr = ["onerror","onload"] >>> example_task(html_attr,"on") ["onerror","onload"] >>> example_task(html_attr,"one") ["onerror"] 

should I use fuzzywuzzy here or what ?

thanks

1 Answer 1

8

No need for some weird libraries, Python has a nice builtin str function called startswith that does just that.

def example_task(words, beginning): return [w for w in words if w.startswith(beginning)] 

Fuzzywuzzy would come in handy if you don't want an exact match.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.