DevJourney

Python/Basics/String/string.py

s=str(input("Enter a string: "))
l=len(s)
sf=("The entire string forward: \n{0} \n\tOR \n{1} \n\tOR \n{2} \n\tOR \n{3}".format(s,s[:],s[0:l],s[-l:]))
sb=("\nThe entire string backward: \n{0} \n\tOR \n{1} \n\tOR \n{2} \n\tOR \n{3}".format(s[::-1],s[-1:-l-1:-1],s[-1:-l-1:-1],s[-1:-l-1:-1]))
saof=("\nAlternate characters of the string (odd) forward: \n{0} \n\tOR \n{1} \n\tOR \n{2} \n\tOR \n{3}".format(s[0:l:2],s[::2],s[:l:2],s[0::2]))
saob=("\nAlternate characters of the string (odd) backward: \n{0} \n\tOR \n{1} \n\tOR \n{2} \n\tOR \n{3}".format(s[-1:-l-1:-2],s[-1::-2],s[-1:-l-1:-2],s[-1::-2]))
saef=("\nAlternate characters of the string (even) forward: \n{0} \n\tOR \n{1} \n\tOR \n{2} \n\tOR \n{3}".format(s[1:l:2],s[1::2],s[1:l:2],s[1::2]))
saeb=("\nAlternate characters of the string (even) backward: \n{0} \n\tOR \n{1} \n\tOR \n{2} \n\tOR \n{3}".format(s[-2:-l-1:-2],s[-2::-2],s[-2:-l-1:-2],s[-2::-2])) 
print("Result >>> {gap}{0}{gap}{1}{gap}{2}{gap}{3}{gap}{4}{gap}{5}{gap}".format(sf,sb,saof,saob,saef,saeb,gap="\n\n\t<========================================>\n\n"))
View on GitHub