Taking input Python

worked, Ty dude ^>

not working, help, im using this code-
t=int(input())
for a in range (0,t):
n=int(input())
s=0
for temp in [int(x) for x in input().split()]:
s=s+temp
print(s)

custom input working all fine but throwing this error without custom input-
Traceback (most recent call last):
File “./prog.py”, line 1, in
EOFError: EOF when reading a line

1 Like

but this will execute every code…no matter what we have written…because it means if my code has any error then just pass…and that’s why it will not show error…after doing this it says “successfully executed” but this doesn’t mean our code is correct and giving the desired output…even if you write a song instead of your code it will get executed successfully.

1 Like

wowwww!! this works…

Try this trick:
try:
//-----Your Code-----
//----Your Code-----
//—Your Code-------
except:
print() #Don’t Pass

import sys
arr = list(map(int, sys.stdin.readline().rstrip().split()))

this should work fine

try using try and except

eg:

try:
# your code here
# try giving input here

except:
pass