part 1: Citizens-of-Zakadaha-hold-an-annual-Gagalafa-festival-to-celebrate-the-harvest-of-their-prized-produce, the-well-sought-after-cocoa-beans-Kokomoko. A-lucky-draw-is-held during-the-festival. Every-participant-is-given-a-lucky draw number. Each year, the organizer decides on two non-zero digits, the factor-digit and the must-have-digit. These two digits need not be distinct. A winning lucky draw number is a number that is a multiple of the factor-digit and contains the must-have-digit. Note that there could be more than one lucky draw winner.
Write function find_winners(factor, must_have, n) that accepts the three parameters:
def find_winners(factor, must_have, n):
for i in range(1, n + 1):
if i % factor == 0 and str(must_have) in str(i):
print('{} is a lucky number'.format(i))
find_winners(2, 3, 50)
30 is a lucky number
32 is a lucky number
34 is a lucky number
36 is a lucky number
38 is a lucky number
Comments
Leave a comment