6. On what principles does Python compare two strings ? Write a program that takes two strings from the user and displays the smaller string in single line and the larger string as per this format :

1st letter last letter
2nd letter 2nd last letter
3rd letter 3rd last letter
:

For example,
if the two strings entered are Python and PANDA then the output of the program should be :
PANDA
P n
y o
t h

Ans:
In python string comparison is done using the ordinal values of the characters in the string. For e.g. ord(‘a’) is 97 and ord(‘A’) is 65, so ‘a’ > ‘A’ is True.
Therefore ‘amen’ > ‘Amen’ is True.

# Code
a = input(‘Enter first string : ‘)
b = input(‘Enter second string : ‘)
a, b = min(a, b), max(a, b) # strings are being compared here, a becomes smaller string and b becomes larger one
print(a)
t = len(b)
for i in range(t//2):
# There will be some spaces before the initial character some spaces in between and then the final character
print(i*’ ‘+b[i]+(t-2*(i+1))*’ ‘+b[-(i+1)]) # this is a complete string formed by concatenating spaces and characters
if t%2 == 1: # if len(b) is odd then we must print the middle character in the last line
print((t//2)*’ ‘+b[t//2])