Advertisement
horozov86

String Explosion

Mar 20th, 2023
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. text = input()
  2. formatted_text = ""
  3. power = 0
  4.  
  5. for idx in range(len(text)):
  6.     if power > 0 and text[idx] != ">":
  7.         power -= 1
  8.  
  9.     elif text[idx] == ">":
  10.         formatted_text += text[idx]
  11.         power += int(text[idx + 1])
  12.     else:
  13.         formatted_text += text[idx]
  14.  
  15. print(formatted_text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement