fork(4) download
  1. #GLOBAL
  2. FIRST = 0
  3.  
  4. def CheckDots(stringIN):
  5. count = 0
  6. isFound = False
  7. index = len(str(stringIN))
  8. for i in range(index):
  9. if (stringIN[i]=='.')&(i==0):
  10. return False
  11. if (stringIN[i] == '.')|(stringIN[i]== '@'):
  12. if (count < 1) & (isFound == True):# & (stringIN[i-2]!='@'):
  13. return False
  14. isFound = True
  15. count = 0
  16. elif isFound == True:
  17. count += 1
  18. if (1<count<4)&(index-count-FIRST-2<=20):
  19. return True
  20. return False
  21.  
  22. def CheckMonkey(stringIN):
  23. count = 0
  24. findDot = False
  25. countDot = 0
  26. for i in range(len(str(stringIN))):
  27. if (findDot == True):
  28. if stringIN[i]!='.':
  29. countDot+=1
  30. else:
  31. if(countDot<1): #& (stringIN[i-2]!='@'):
  32. return False
  33. findDot = False
  34. if stringIN[i] == '@':
  35. if(i>20)|(i==0):
  36. return False
  37. global FIRST
  38. FIRST = i
  39. count+=1
  40. findDot = True
  41. if (count == 1) & (findDot == False):
  42. return True
  43. else:
  44. return False
  45.  
  46. def FindSpace(stringIN):
  47. for i in range(len(str(stringIN))):
  48. if stringIN[i] == ' ':
  49. return True
  50. return False
  51.  
  52. def CheckSpelling(stringIN):
  53. for i in range(len(str(stringIN))):
  54. value = ord(stringIN[i])
  55. if ((ord('a')<=value<=ord('z'))|(ord('A')<=value<=ord('Z'))|(ord('0')<=value<=ord('9'))|(value==ord('@'))|(value==ord('_'))|(value==ord('.')))==False:
  56. return False
  57. return True
  58.  
  59.  
  60. n = int(raw_input())
  61.  
  62. for i in range(n):
  63. stringIN = str(raw_input())
  64. if(CheckSpelling(stringIN) == True)&(CheckMonkey(stringIN) == True)&(CheckDots(stringIN) == True)&(FindSpace(stringIN) == False):
  65. print 'Tak'
  66. else:
  67. print 'Nie'
Success #stdin #stdout 0.02s 6972KB
stdin
1
123.123@123.pl
stdout
Tak