Spot some numbers X61233


Statement
 

pdf   zip   main.py

Write a function spot_them that receives a list of integers lstlst and an integer k,0k9k, 0\le{k}\le9 and returns a list with the positions in lstlst that contain a number with the digit kk.

def spot_them(lst, k) :
    '''
    >>> spot_them([23, 455, 0, -12, 51], 5)
    [1, 4]
    >>> spot_them([205, 28, 94, 2], 2)
    [0, 1, 3]
    >>> spot_them([7, 8, 0, 33], 4)
    []
    '''

For instance, if lst=[23,455,0,-12,51] and k=5, the result should be [1,4] since those are the positions in lst containing numbers with the digit 5.

Important: Only the function will be evaluated. If you submission includes a main program, it must be either commented out, or under the condition     if __name__ == ’__main__’:

Sample session
>>> spot_them([23, 455, 0, -12, 51], 5)
[1, 4]
>>> spot_them([205, 28, 94, 2], 2)
[0, 1, 3]
>>> spot_them([7, 8, 0, 33], 4)
[]
Information
Author
ProAl professors
Language
English
Official solutions
Python
User solutions
Python