InterviewSolution
Saved Bookmarks
| 1. |
Create a function countPages(x) that takes the number of pages of a book as an argument and counts the number of times the digit ‘1’ appears in the page number. |
|
Answer» Answer: def countPages(num): total = 0 i = 1 while i<=num: page_no = str(i) total + = page_no.count(‘1’) i+ = l return total |
|