0
Please whatâs wrong with this
for n in range(str(input())): text = str(input()) print('{} {}'.format(text[::2], text[1::2])
12 Answers
+ 1
Mirielle still saying error
+ 1
What is the error message?
+ 1
What do you want the code to actually do?
+ 1
it should print the even index of a string on one side and odd index on another side
+ 1
I guess you meant it should print out the letters with even indices on one side and that of odd indices on the other side.
Then you could do something like...
text = input()
print('{} {}'.format(text[::2], text[1::2]))
Your current code didn't work because the argument of the range function is a string. Also setting text = str(input()) inside the for loop will require multiple inputs.
+ 1
Didnt work also Jolomi Tosanwumi
+ 1
It worked on my end...hope you're not making any mistake in syntax.
+ 1
for n in range(int(input()):
text = input()
print('{} {}'.format(text[::2], text[1::2])
+ 1
is that the same as yours?
+ 1
No...it is
text = input()
print('{} {}'.format(text[::2], text[1::2]))
+ 1
wow. it worked. thanks so much