fork download
  1. from collections import Counter
  2.  
  3.  
  4. def has_char_with_exactly_two_repeats(line):
  5. char_counts = Counter(line)
  6. return 2 in char_counts.values()
  7.  
  8.  
  9. def main():
  10. print('Use Ctrl + C to exit the program.')
  11. try:
  12. while True:
  13. line = input().strip()
  14. if has_char_with_exactly_two_repeats(line):
  15. print(line)
  16. except EOFError:
  17. pass
  18. except KeyboardInterrupt:
  19. pass
  20.  
  21.  
  22. main()
  23.  
  24.  
Success #stdin #stdout 0.03s 9832KB
stdin
asdf
fdas
asds
d fm
dfaa
aaaa
aabb
aaabb
stdout
Use Ctrl + C to exit the program.
asds
dfaa
aabb
aaabb