I have two strings , the length of which can vary based on input. I want to format them aligning them to middle and filling up the rest of the space with ' '
. Each string starting adn ending with ^^
.
Case1:
String1 = Longer String
String2 = Short
Output required:
^^ Longer String ^^
^^ Short ^^
Case2:
String1 = Equal String1
String2 = Equal String2
Output required:
^^ Equal 1 ^^
^^ Equal 2 ^^
Case3:
String1 = Short
String2 = Longer String
Output required:
^^ Short ^^
^^ Longer String ^^
Across all three outputs the legth has been kept constant , so that uniformity is maintained.
My initial thought is that this will involve checking lengths of the two strings in the following format
if len(String1) > len(String2):
#Do something
else:
#Do something else