Skip to content

Instantly share code, notes, and snippets.

@washingtonsoares
Created May 14, 2022 11:05
Show Gist options
  • Save washingtonsoares/9175ffae5c05d5fb3ff0d0a9fef73b4e to your computer and use it in GitHub Desktop.
Save washingtonsoares/9175ffae5c05d5fb3ff0d0a9fef73b4e to your computer and use it in GitHub Desktop.
while True:
try:
text = input()
shortcuts = []
resultText = ""
for i in range(len(text)):
currentChar = text[i]
if (currentChar == "_"):
if (len(shortcuts) > 0 and shortcuts[-1] == "_"):
shortcuts.pop()
resultText += "</i>"
else:
shortcuts.append("_")
resultText += "<i>"
elif (currentChar == "*"):
if (len(shortcuts) > 0 and shortcuts[-1] == "*"):
shortcuts.pop()
resultText += "</b>"
else:
shortcuts.append("*")
resultText += "<b>"
else:
resultText += currentChar
print(resultText)
except EOFError:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment