Q.30

PHOTO EMBED

Sat Jan 08 2022 13:05:02 GMT+0000 (Coordinated Universal Time)

Saved by @di


"""
30.Write a Python program to get a single string from two given strings, separated by a space and swap the first two characters of each string. 
Sample String : 'abc', 'xyz' 
Expected Result : 'xyc abz'
"""

str1,str2='abc','xyz' 
s1 = str2[:2] + str1[2:]
s2 = str1[:2] + str2[2:]
print(s1,s2)
content_copyCOPY

https://www.onlinegdb.com/online_python_compiler