Beginner in python here, and I have a code that is supposed to slice a string evenly and oddly and display it.
Here is my code:
def even_bits(str):
result = ""
for i in range(len(str)):
if i % 2 == 0:
result = result + str[i]
return result
def odd_bits(str):
result = ""
for i in range(len(str)):
if i % 2 == 1:
result = result + str[i]
return result
for i in range(int(input())):
w = input('')
print(even_bits(w), ' ' ,odd_bits(w))
This runs correctly however gives output as follows:
Sample Input:
2
Hello
World
Sample Output:
2
Hello
Hlo el
World
Wrd ol
How do I format the output such that I get output as follows:
Sample Output:
Hlo el
Wrd ol
Thank You in advance.