Assign a number and statistics

Enter a number string and a numeric character (1-9), count the number of the figure appearing in the string, and accumulates. For example, a string 1,234,321, to find the figure 2, appears twice in the string, and so accumulated is 2 + 2 = 4

Input formats:

Enter two lines. Line 1 is the string, the second line is the number you are looking for.

Output formats:

Specifies the number that appears accumulate and

Sample input:

1234321
2
 

Sample output:

4
n=str(input())
p=str(input())
print(n.count(p)*int(p))

  

Guess you like

Origin www.cnblogs.com/SkystarX/p/12334055.html
Recommended