229k views
24 votes
Learning python and am confused on how to code this problem in order for the function to return these statements... please help!

Learning python and am confused on how to code this problem in order for the function-example-1
User SAaNu
by
6.1k points

1 Answer

10 votes

Answer:

def k_in_num(k, num):

if (k == 0): return False

return str(k) in str(num)

Step-by-step explanation:

A bit weird that 0 doesn't contain 0, but anyway, above code does what you want.

User Marc Lambrichs
by
5.0k points