Advertisement
go6odn28

While_more_exercises_3_steam_of_letters

Oct 6th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. command = input()
  2. word = ''
  3. secret_command_c = 0
  4. secret_command_o = 0
  5. secret_command_n = 0
  6. last_word = ''
  7.  
  8. while command != 'End':
  9.     if command.isalpha():
  10.         if secret_command_c >= 1 and secret_command_o >= 1 and secret_command_n >= 1:
  11.             word += ' '
  12.             secret_command_c = 0
  13.             secret_command_o = 0
  14.             secret_command_n = 0
  15.             last_word += word
  16.             word = ''
  17.             continue
  18.         if command == 'c':
  19.             secret_command_c += 1
  20.             if secret_command_c > 1:
  21.                 word += command
  22.         elif command == 'o':
  23.             secret_command_o += 1
  24.             if secret_command_o > 1:
  25.                 word += command
  26.         elif command == 'n':
  27.             secret_command_n += 1
  28.             if secret_command_n > 1:
  29.                 word += command
  30.         else:
  31.             word += command
  32.  
  33.     command = input()
  34.  
  35. if secret_command_c >= 1 and secret_command_o >= 1 and secret_command_n >= 1:
  36.     word += ' '
  37.     last_word += word
  38. print(last_word)
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement