Problem statement:
We need to create a secret message in Python by mirroring a string. We will be given a string, first, we need to convert it to lowercase, then we need to find its mirror string. How? We need to break 26 alphabets into two half-equal parts, and place them above one another, now check what is the first letter of your string, check that letter in the two half parts of the alphabets, and find its mirror letter. Check the image below for a better understanding.
For example, for copyassignment, the output will be=> xlkbzhhrtmnvmg.
Code for Secret Message in Python:
# declaring a string mystr = 'CopyAssignment' #making mystr to lower case mystr = mystr.lower() # storing alphabets in two half parts, to be used for mirroring alphabets1 = 'abcdefghijklm' alphabets2 = 'zyxwvutsrqpon' # declaring a list to store new string letters strlist = [] # looping over string for i in mystr: # declaring a counter ctr = 0 if i in alphabets1: for j in alphabets1: if i==j: strlist.append(alphabets2[ctr]) else: ctr += 1 else: for j in alphabets2: if i==j: strlist.append(alphabets1[ctr]) else: ctr += 1 # printing the list by conerting it to string print(''.join(strlist))
Output:
Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- Team Points in Python
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Split the sentence in Python
- String Slicing in JavaScript
- First and Last Digits in Python | Assignment Expert
- List Indexing in Python
- Date Format in Python | Assignment Expert
- New Year Countdown in Python
- Add Two Polynomials in Python
- Sum of even numbers in Python | Assignment Expert
- Evens and Odds in Python
- A Game of Letters in Python
- Sum of non-primes in Python
- Smallest Missing Number in Python
- String Rotation in Python
- Secret Message in Python
- Word Mix in Python
- Single Digit Number in Python
- Shift Numbers in Python | Assignment Expert
- Weekend in Python
- Shift Numbers in Python | Assignment Expert
- Temperature Conversion in Python
- Special Characters in Python
- Sum of Prime Numbers in the Input in Python