Answer to Question #285181 in Python for Jhonny

Question #285181

2. Found Ya!

by CodeChum Admin

Let's now try finding a certain digit into an integer! Come and join in on the fun and code with me!


Instructions

  1. Create two variables assigned to an input() function. The first one shall accept any integer from 0-9 and the other one shall take a random positive integer. All the needed values are to be inputted in one single line.
  2. Using loops, identify if the number (0-9) is present in the given positive integer. If it is found, print "Yes"; else, print "No".
  3. Tip: If the number is already found even without reaching the end of the loop, use the break keyword to exit the loop early for a more efficient code.

Input

A line containing two integers separated by a space.

1·231214238

Output

A line containing a string.

Yes





1
Expert's answer
2022-01-06T02:01:08-0500
inputValues=input().split(' ')
digit=int(inputValues[0])
number=int(inputValues[1])
count=0
while number>0:
    if number % 10 == digit:
        count +=1
    number = int(number/10)
if count>0:
    print("Yes")
else:
    print("No")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS