I'm a Python newbie, and I've written some code that should slice text evenly and weirdly and show it.
This is my code:
This works perfectly, however the result is as follows:
How do I format the output such that it looks like this:
I'm still learning how to use the string-slicing function for resources like this, so I was hesitant to use it.
Thank you ahead of time.
This is my code:
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))
Code:
Sample Input:
2
Hello
World
Sample Output:
2
Hello
Hlo el
World
Wrd ol
Code:
Sample Output:
Hlo el
Wrd ol
Thank you ahead of time.