Swapping contents from one string to another string and display the modified strings using Python.
Two strings string 1 and string 2 are given as input. The contents from string 1 are copied to string 2 and the contents from string 2 are copied to string 1. Now, string 1 contains contents of string 2 and string 2 contains contents of string 1.Both modified strings are displayed as output.
For example,
string1='cat'
string2='dog'
Now, The contents from string 1 are copied to string 2 and the contents from string 2 are copied to string 1. The modified strings look like.
string1='dog'
string2='cat'
Submitted by Tharunkumar C (tharun2k1)
Download packets of source code on Coders Packet
Comments