Python, Error while taking input

Reason of Error:- codechef testcases dont give “/n” i.e. enter (newline charecter) at the end of the input, which is fine with most programming languages like c and c++ but python input() only returns the value after it encounters a newline. so now u may be wondering how to solve this problem.

Solution:-

  1. switch to Non-IDE Mode.
  2. Use input().split() instead of input()
    note:- in 2nd solution split() turns the input() str into a list divided by whitespaces.
    also note that there is no argument in () of split().

I wrote down a code. on giving custom input it ran fine . But on submitting it ,it still gave me nzec error .Can you please tell me how to remove that

absolutely Thanks man !

hey thanks bro!!

Put all of your code in try and except blocks.

like,

try:
-----
except:
pass

It helped me. I hope it helps you too :slight_smile:

that means, your code breaks somewhere, just see if you are accessing something out of bound, allocating too much memory or something else