Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import sys
  2. n = str(sys.argv[1]) # n = sys.argv[1] також не працює
  3.  
  4. def count_holes(n):
  5.     n = n.lstrip('0')
  6.     if n[0] == '-' or n[0] == '+':
  7.         n = str(n[1:])
  8.  
  9.     if type(n) == int or n.isdigit():
  10.         new = str(n)
  11.         count = 0
  12.         for x in new:
  13.             if x == '0':
  14.                 count += 1
  15.             if x == '4':
  16.                 count += 1
  17.             if x == '6':
  18.                 count += 1
  19.             if x == '9':
  20.                 count += 1
  21.             if x == '8':
  22.                 count += 2
  23.         return count
  24.     else:
  25.         print 'ERROR'
  26.  
  27. print count_holes(n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement