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:-
switch to Non-IDE Mode.
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
Put all of your code in try and except blocks.
like,
try:
-----
except:
pass
It helped me. I hope it helps you too
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 Python Tutorial
online compile.
Thanks.
t = 0
try:
t = input(“Please input your name:”)
except:
pass
print(t)
gurr_i
July 10, 2021, 5:24pm
72
I would suggest you use this method for taking input from users for the list in python. it works perfectly
import sys
def get_ints(): return list(map(int, sys.stdin.readline().strip().split()))
LIST = get_ints()
ssjgz
July 28, 2021, 6:30pm
74
Please post a link to your submission.
joffan
July 29, 2021, 4:11pm
75
@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.
stash
August 11, 2021, 8:53am
78
I think this error occurs when input are on same line and you take input like this
a=int(input)
b=float(input)
Instead take input like this
a , b = input().split()
a = int(a)
b = float(b)
It will work.
i gave a custom input and got a output too but got another error.
joffan
October 17, 2021, 8:22pm
81
@shailly_raj Looks like you’re trying to read a line of input for a fourth case, for some reason. Are you handling the number of cases properly?
1 Like
@joffan I want to ping you personally. Can u share your linkedin id or insta id ?
joffan
October 19, 2021, 5:12pm
83
You can find me on Twitter (@Joffan7 )