Find word by given characters

MRAB python at mrabarnett.plus.com
Sat Oct 31 21:52:54 EDT 2020


On 2020-11-01 00:36, 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".
> 
> Here is a link to the code:
> https://bpa.st/UTAA
> 
> Thanks in advance
> 
This is what's happening in the inner loop:

Iteration 1: word contains 1 of 'a', letters contains 2 of 'a', so don't 
print the word.

Iteration 2: word contains 1 of 't', letters contains 1 of 't', so print 
the word.


More information about the Python-list mailing list