Advertisement
ALEXANDAR_GEORGIEV

stream_of_letters

Jun 8th, 2022 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. list_words = []
  2. c = 0
  3. o = 0
  4. n = 0
  5. cc = False
  6. oo = False
  7. nn = False
  8. check_last_word = True
  9. while True:
  10.     letter = input()    # c, o, n срещнат ли се по 1 път се изписва дума,
  11.     if letter == 'End':
  12.         check_last_word = False
  13.         break
  14.     if letter == 'c':
  15.         c += 1
  16.         cc = True
  17.         if c > 1:
  18.             list_words.append(letter)
  19.     elif letter == 'o':
  20.         o += 1
  21.         oo = True
  22.         if o > 1:
  23.             list_words.append(letter)
  24.     elif letter == 'n':
  25.         n += 1
  26.         nn = True
  27.         if n > 1:
  28.             list_words.append(letter)
  29.     else:
  30.         if letter.isalpha():
  31.             list_words.append(letter)
  32.     if cc and oo and nn:
  33.         list_words.append(' ')
  34.         cc = False
  35.         oo = False
  36.         nn = False
  37.         c = 0
  38.         o = 0
  39.         n = 0
  40. if not check_last_word:
  41.    for y in range(len(list_words) - 1, 0 - 1, -1):
  42.         if list_words[y] != ' ':
  43.             list_words.pop()
  44.         elif list_words[y] == ' ':
  45.             break
  46.  
  47. for x in list_words:
  48.         print(x, end='')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement