Sichanov

stream_of_letters

Feb 7th, 2021
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. command = input()
  2. c_counter = 0
  3. o_counter = 0
  4. n_counter = 0
  5. c_is_found = False
  6. o_is_found = False
  7. n_is_found = False
  8. word = ""
  9. while command != 'End':
  10.     current_symbol = command
  11.     symbol = ord(current_symbol)
  12.     if 65 <= symbol <= 90 or 97 <= symbol <= 122:
  13.         if current_symbol == 'c':
  14.             if c_counter >= 1:
  15.                 word += current_symbol
  16.             else:
  17.                 c_counter += 1
  18.                 c_is_found = True
  19.         elif command == 'o':
  20.             if o_counter >= 1:
  21.                 word += current_symbol
  22.             else:
  23.                 o_counter += 1
  24.                 o_is_found = True
  25.         elif command == 'n':
  26.             if n_counter >= 1:
  27.                 word += current_symbol
  28.             else:
  29.                 n_counter += 1
  30.                 n_is_found = True
  31.         else:
  32.             word += current_symbol
  33.         if c_is_found and o_is_found and n_is_found:
  34.             print(f'{word}', end =' ')
  35.             c_counter = 0
  36.             o_counter = 0
  37.             n_counter = 0
  38.             c_is_found = False
  39.             o_is_found = False
  40.             n_is_found = False
  41.             word = ''
  42.     command = input()
  43.  
Advertisement
Add Comment
Please, Sign In to add comment