I ma getting RunTime error in CleanUP problem

Here is my


[1]
Please help!


  [1]: https://www.codechef.com/viewsolution/15581231

T=int(input()) for i in range(T): #cj=[] n,m=map(int,input().split(' ')) cj=list(map(int,input().split(' '))) #cj.extend(ele) fele=[j for j in range(1,n+1)] ex = [x for x in fele if x not in cj] chef=[e for c,e in enumerate(ex) if c%2==0] other=[e for d,e in enumerate(ex) if d%2==1] for l in chef[:]: print(l,end=' ') print() if not other: print() else: for m in other: print(m,end=' ')

Runs fine in repl.it and terminal.
No clue why this might be happening? Little help can push me alot ahead. Thanks

1 Like

@bgulati1994 Couple of things from your code above…

Why don’t you just print the “other” the same way as the “chef”? You seem to miss an endline on other when there are jobs to do, unless you snipped that by accident.

Also note for full slice usage that chef’s jobs are ex[::2] and other’s jobs are ex[1::2] - the final “2” being the step. Slicing will return an empty list if appropriate.

Another neat feature you can use here is unpacking; prefacing an iterable with an asterisk in a function call presents the contained items as a list of parameters, so print(*ex[::2]) should print the jobs of interest for chef.