boris-vlasenko

111321 IP-адрес

Mar 25th, 2016
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. file = open('input.txt', encoding='utf-8')
  2. line = file.readline()+'.'
  3. file.close()
  4.  
  5. point = 0
  6. num = ''
  7. res = 'NO'
  8. for s in line:
  9.     if point <= 3:
  10.         if s in '0123456789':
  11.             num += s
  12.         else:
  13.             if num and s == '.' and 0 <= int(num) <= 255:
  14.                 point += 1
  15.                 num = ''
  16.             else:
  17.                 break
  18.  
  19. if point == 3 and num and 0 <= int(num) <= 255:
  20.     res = 'YES'
  21.                
  22. print(res)
Advertisement
Add Comment
Please, Sign In to add comment