Home > OS >  How to rotate a character by 90 degrees in python?
How to rotate a character by 90 degrees in python?

Time:02-14

I'm trying to rotate the character | sideways by 90 degrees, think of a longer - and then print it.

would appreciate the help as to how I can do that?

CodePudding user response:

Can you just print an em dash, "—"? In many fonts, an em dash is as long as the font's letters are tall.

If this doesn't answer your question, could you please clarify why you need to rotate the "|", rather than just print "—"?

CodePudding user response:

For converting '|' char to 90 degree, we can replace with all chars '|' to '—' chars.


s1 = "Example | text | with | horizontal | string"

def RotateCharacter90(s1):
    s2 = s1.replace( "|", "—")
    return s2

print(RotateCharacter90(s1))

""" OUTPUT: Example — text — with — horizontal — string """
  • Related