On 2020-11-01, Bischoop <[email protected]> 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".
>
Problem's solved.
------------
for word in words:
if all(word.count(x) == letters.count(x) for x in letters):
print(word)
-------------
Thanks for suggestions, I didn't had to use counter but going to look
into as it seems useful and interesting.
Thank You
--
https://mail.python.org/mailman/listinfo/python-list