Task
Given a string, , of length that is indexed from to , print its even-indexed and odd-indexed characters as
space-separated strings on a single line (see the Sample below for more detail).
Note:
0 is considered to be an even index.
Example
s = adbefc
Print abc def
Input Format
The first line contains an integer,
(the number of test cases).
Each line of the subsequent lines contain a string,
Constraints
1<= T<=10
2 <= length of s <10000
Output Format
For each String
(where ), print 's even-indexed characters, followed by a space, followed by
's odd-indexed characters.
Sample Input
2
Hacker
Rank
Sample Output
Hce akr
Rn ak
Program in Python
#program in python
s=int(input())
for i in range (s):
string=input()
even=''
odd=''
for j in range(len(string)) :
if j%2==0:
even+=string[j]
else:
odd+=string[j]
print('{} {}'.format(even,odd))
Input :
2
Hacker
Rank
Output :
Hce akr
Rn ak
Comments
Post a Comment
Type Your Comments !
Please do not enter any spam link in the comment box.