511,033 views
41 votes
41 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 Ezequiel Marquez
by
3.0k points

1 Answer

17 votes
17 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 Robdodson
by
2.7k points