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.


  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().
1 Like

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.



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

The code below when print(t), t = 0, how to let the input() get the data from me at IDE mode, I use
online compile.

t = 0

t = input(“Please input your name:”)


I would suggest you use this method for taking input from users for the list in python. it works perfectly :innocent:

import sys
def get_ints(): return list(map(int, sys.stdin.readline().strip().split()))
LIST = get_ints()

not working at all

Please post a link to your submission.

@japatpreet don’t use the psyco module; it’s not part of the standard library.

If you want to work with compiled Python code, just code under the PyPy language option.

I am currently learning Python from YouTube, as a beginner it is little bit difficult to understand.

I think this error occurs when input are on same line and you take input like this


Instead take input like this

a , b = input().split()

a = int(a)

b = float(b)

It will work.

lifesaver lol