I need to create a function which will return two lists. First there is a list of stars that have "found" and "dummy" element, where the numbers are equal in two lists. The second list contains a fixed number integer, the range parameter is given by "colors" which gives the amount of time of a specific number. At present, I have completed the first list, but in the second list, I am quite confused. In addition, you have to use the recycling process. Here is the code
def search (code, estimate, color): if you guess == []: return [] and: if guessed [0] == code [0]: returns ["Found"] + find (code [1:], guess [1:], color) Other: Return ["dummy"] + Find (code [1:], guess [1:], color) < / Code>
A possible result will appear like this:
& gt; & Gt; & Gt; ([1,2,3], [3,2,1], 6) Find [['dummy', 'found', 'dummy]], [0, 0, 1, 0, 0]] < / Code>
I had to go for something like this:
< Code DEF Search (code, estimation, color): Def sub (code, estimate, lst1, lst2): If the guess is: [0] == Code [0]: lst2 [code [0]] + Returns (code [1:], estimation [1:], estimate [1:], lst1 + ["found"], lst2) Other: return sub (code [1:], estimation [1:], lst1 + ["dummy" ], Lst2) Other: return lst1, lst2 return sub (code, estimate, [], [0] * color)then
> ; & Gt; & Gt; Print (find ([1,2,3], [3,2,1], 6)) (['dummy', 'found', 'dummy'], [0, 0, 1, 0, 0, 0 )])
Comments
Post a Comment