Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
-3 bytes (and a bug fix) thanks to Felipe Nardi Batista
i=0 for c in input():i-=i and c<'<';print'=c<'<'*i;print' '*i+c;i+=c>'<'
Try it online!Try it online!
i=0 for c in input():i-=i and c<'<';print' '*i+c;i+=c>'<'
Try it online!
i=0 for c in input():i-=c<'<'*i;print' '*i+c;i+=c>'<'
i=1i=0 for c in input():i-=c<'<';print'=i and c<'<';print' '*i+c;i+=c>'<'
The extra space is allowed in the rulesTry it online!
Each line may have extra trailing whitespace as long as this doesn't change the visual appearance of the output.
-3 bytes thanks to Felipe Nardi Batista
i=1 for c in input():i-=c<'<';print' '*i+c;i+=c>'<'
The extra space is allowed in the rules