Advertisement
strajkovski

Untitled

Mar 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. string = input()
  2.  
  3. def scan_pairs(to_scan):
  4.     pairs = list()
  5.  
  6.     for i in range(len(to_scan)):
  7.         if i < len(to_scan)-1:
  8.             if ' ' not in to_scan[i] and ' ' not in to_scan[i+1]:
  9.                 pairs.append(to_scan[i]+to_scan[i+1])
  10.  
  11.     return pairs
  12.  
  13. def most_common(to_scan):
  14.     pairs = scan_pairs(to_scan)
  15.     count = 0
  16.     m_count = 0
  17.     the_pair = ""
  18.     for i in range(len(pairs)):
  19.         current_pair = pairs[i]
  20.         for j in range(len(pairs)):
  21.             if current_pair == pairs[j]:
  22.                 count += 1
  23.  
  24.         if count >= m_count:
  25.             m_count = count
  26.             the_pair = current_pair
  27.  
  28.         count = 0
  29.     return the_pair
  30.  
  31. print(most_common(string))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement