So I just wanted to try my hands on python . So I started learning it and the most obvious is to try out the simplest programs in it , so that I could get a go on the syntax . Well I got stuck on the first one only . The error is Runtime Error. Tried various version of the code for some time now but nothing is working . So here is the code
Ideone link : https://www.ideone.com/3GfMjy
Link : https://www.codechef.com/problems/CLEANUP
“0 ≤ m ≤ n ≤ 1000…The second line contains a list of m distinct integers between 1 and n.”
If M == 0, int(jobs_done[x])) will trow an error since x will be ‘’.
You can avoid this by using ‘jobs_done=input().split()’ instead of ‘jobs_done=input().split(’ ‘)’.
You btw do not need semicolons in python to indicate the end of statement.
I was trying to find the error for soooo loooong (last 30 mins!!)… Everything seemed fine, still it didn’t pass. I was getting irritated. BTW, nice observation. +1
Glad it worked. documentation on split(): https://docs.python.org/3/library/stdtypes.html#str.split “If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace. Consequently, splitting an empty string or a string consisting of just whitespace with a None separator returns ”