Advertisement
jbn6972

Untitled

Sep 14th, 2022
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #Code Written by : John Nixon
  2. #Date: 14:09:2022  Time: 22:39:59
  3. #Copyrights are applicable
  4.  
  5. import sys
  6. import os
  7. sys.setrecursionlimit(10000)
  8. try:
  9.     sys.stdin = open('./input.txt', 'r')
  10.     sys.stdout = open('./output.txt', 'w')
  11. except:
  12.     pass
  13.  
  14. def distinct_years(sentence):
  15.     different_years = set()
  16.     str2 = ""
  17.     for char in sentence:
  18.         if char.isdigit():
  19.             str2 += char
  20.  
  21.         if char == "-":
  22.             str2 = ""
  23.                
  24.         if len(str2) == 4:
  25.             different_years.add(str2)
  26.             str2 = ""
  27.        
  28.     return len(different_years)
  29.            
  30.    
  31. string = input()
  32.  
  33. print(distinct_years(string))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement