Swapping Two Strings in Python

Tharunkumar C Mar 03, 2021

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'

 

Project Files

Loading...
..
This directory is empty.

Comments (0)

Leave a Comment