Find word by given characters
Terry Reedy
tjreedy at udel.edu
Sat Oct 31 22:04:22 EDT 2020
On 10/31/2020 8:36 PM, Bischoop wrote:
> I'm working on a script i which user inputs letters and then a printed
> words containing those letters. The scripts works however I can't solve
> one problem , it prints also words in which these letters occur more
> than once.
> -------------------
> Fore example:
> Letters: at
> Output: auto, autobahn.
> -------------------
>
> I supposed to not print word: "autobahn" because I've given it only one
> letter "a".
If you use collections.counter on both the letters and the word, you
could check that the counts in letters are matched by the counts for
word. Make sure to use 'and' between count matches.
--
Terry Jan Reedy
More information about the Python-list
mailing list