Answer to Question #306766 in Python for reyadh

Question #306766

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'

1
Expert's answer
2022-03-06T14:04:32-0500
s1, s2 = input(), input()
print(f"{s2[-1]}{s1[-1]}{s2[0]}{s1[0]}")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS