The program takes two strings as input, and then computes the intersection of the characters that appear in both strings. The program then prints the original strings and the intersection to the console.
The program initializes two string variables str1 and str2 with the values "UpperCase" and "LowerCase" respectively. These strings represent the input strings that will be used to compute the intersection.
The program then prints the original input strings to the console using the print() function. Next, the program initializes an empty string res which will store the characters that are present in both input strings.
The program then enters a loop that iterates over each character in the first input string str1. For each character, the program checks if it is also present in the second input string str2, and if it is not already in the res string. If both conditions are true, then the character is added to the res string using the += operator.
After all characters in the first input string have been checked and added to the res string if they are also present in the second input string, the program prints the intersection of the two input strings to the console using the print() function.
str1 = "UpperCase" str2 = "LowerCase" print("Original strings:") print(str1) print(str2) res = "" for ch in str1: if ch in str2 and not ch in res: res += ch print("Intersection of two said String:",res)
Original strings: UpperCase LowerCase Intersection of two said String: erCas
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions