Advertisement
GalinaKG

Stream of letters - PB SoftUni

May 20th, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. command = input()
  2. valid_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  3. is_c = False
  4. is_o = False
  5. is_n = False
  6. secret = ""
  7. secret_word = ""
  8.  
  9. while command != "End":
  10.     current_symbol = command
  11.  
  12.     if current_symbol not in valid_letters:
  13.         command = input()
  14.         continue
  15.  
  16.     if current_symbol == "c":
  17.         if not is_c:
  18.             is_c = True
  19.         else:
  20.             secret += current_symbol
  21.  
  22.     elif current_symbol == "o":
  23.         if not is_o:
  24.             is_o = True
  25.         else:
  26.             secret += current_symbol
  27.     elif current_symbol == "n":
  28.         if not is_n:
  29.             is_n = True
  30.         else:
  31.             secret += current_symbol
  32.  
  33.     if current_symbol not in ["c", "o", "n"]:
  34.         secret += current_symbol
  35.  
  36.     secret_word = secret
  37.  
  38.     if is_c and is_o and is_n:
  39.         print(secret_word, end=" ")
  40.         secret = ""
  41.         is_c = False
  42.         is_o = False
  43.         is_n = False
  44.  
  45.     command = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement