Click here to Skip to main content
15,668,842 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,
I am getting
"stdout error"  on executing below code in interpreter.

Expected Output: should print even index character and then space and then odd index character in from given input string

What I have tried:

def stdin(s):
    if (len(s)>=2 and len(s)<=10000):
        ev=[s[i] for i in range(len(s)) if i%2==0]
        od=[s[i] for i in range(len(s)) if i%2!=0]
        print("{0} {1}".format(even,odd))
if __name__ == '__main__':
    s = input().strip()
Updated 15-May-22 19:03pm
Richard MacCutchan 16-May-22 3:47am    
The code works fine for me. Where are you running it?

1 solution

I don't.
If I copy'n'paste your code into an online Python interpreter (OnlineGDB[^]) and run it, I get what you expect:

So ... what am I doing that you aren't, or vice versa?
Share this answer
SUBODH SINGH May2022 16-May-22 6:25am    
thanks for support, now i got the solution. Actually, test case requirement was that i need to take 2 inputs from user, But i was taking only one input from user so thats why my test case was getting failed.

thanks for giving time to my problem.
OriginalGriff 16-May-22 6:39am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900