Count the number occur in between 1 to 100 in python by R4R Team


program-

count=0
print("Enter number to count in between 1 and 100")
n=input()
for i in range(1,101):
count=count+str(i).count(n)

print("Number of 7 in between 1 and 100 is:",count)


output-

Enter number to count in between 1 and 100
7
Number of 7 in between 1 and 100 is: 20

Enter number to count in between 1 and 100
0
Number of 7 in between 1 and 100 is: 11


-In this program, we count the number in between the 1 and 100
- 0 in between 1 and 100 are occur in 10,20,30,40,50,60,70,80,90,100, there are 11 0's in this range.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!