Special alphabetical order Infosys springboard coding question with solution

Problem Statement :

Given a non-empty string instr containing only alphabets, print the string outstr by arranging the alphabets of instr in the following order:

AaBb……YyZz

i.e. all occurrences of ‘A’ in instr will come first, followed by all occurrences of ‘a’, then all occurrences of ‘B’ and so on.

Input format:

Read the string instr from the standard input stream.

Output format:

Print outstr to the standard output stream.

Question :

Code Solution :

				
					instr =input()
outstr = ''
for i in 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz':
    for j in instr:
        if i == j:
            outstr+=i

print(outstr)
				
			

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *