Suppose you are given two strings, s1, and s2. Now, print a new string made up of the last characters and then the first characters of the input strings.
=====================================================================
Sample Input 1:
s1 = new
s2= string
Sample Output 1:
gwsn
Explanation: The last character of the String s2 is 'g'. The last character of the String s1 is 'w'. The first character of the String s2 is 's'. The first character of the String s1 is 'n'. Together they give us the ouput we want 'gwsn'.
=====================================================================
Sample Input 2:
s1 = abcd
s2= efgh
Sample Output 2:
hdea
Explanation: The last characters of the Strings s2 and s1 is 'h' and 'd' respectively while the first characters of the Strings is 'e' and 'a' respectively. Together they give us the ouput we want 'gwsn'
s1, s2 = input(), input()
print(f"{s2[-1]}{s1[-1]}{s2[0]}{s1[0]}")
Comments
Leave a comment