We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Compliation output sucessful, but Test Case getting fail.
def char_indexing(input_string):
even_str = []
odd_str = []
if 2 <= len(input_string) <= 10000:
for s in range(len(input_string)):
if s % 2 == 0:
even_str.append(input_string[s])
else:
odd_str.append(input_string[s])
even_str.insert(len(even_str) + 1, ' ')
return even_str+odd_str
t = int(input("\n"))
if 1 <= t <= 10:
for i in range(t):
input_string = input().strip()
output = char_indexing(input_string)
if(output != ''):
print(''.join(output))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 6: Let's Review
You are viewing a single comment's thread. Return to all comments →
Compliation output sucessful, but Test Case getting fail. def char_indexing(input_string): even_str = [] odd_str = [] if 2 <= len(input_string) <= 10000: for s in range(len(input_string)): if s % 2 == 0: even_str.append(input_string[s]) else: odd_str.append(input_string[s]) even_str.insert(len(even_str) + 1, ' ') return even_str+odd_str
t = int(input("\n")) if 1 <= t <= 10: for i in range(t): input_string = input().strip() output = char_indexing(input_string) if(output != ''): print(''.join(output))