Create a string from two strings

In this program, we will take two strings as input and create a string from two strings combining uncommon characters of the said strings. 

Steps to solve the program
  1. Take two strings as input.
  2. Create an empty string.
  3. Using for loop add characters from string 1 to the empty string which is not in string 2.
  4. Repeat this process for string 2.
  5. Print the output.
				
					#Input string
str1 = "abcdefg"
str2 = "xyzabcd"
str3 = ""

for char in str1:
    if char not in str2:
        str3 += char
for char in str2:
    if char not in str1:
        str3 += char

#Printing output        
print(str3)
				
			

Output :

				
					efgxyz
				
			

Create a string that consists of multi-time occurring characters in the said string

remove all characters except the given character in a string. 

Leave a Comment