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

Thanks so much dude!! It really worked!

n=int(input())
for i in range(n):
a,b= map(int, input().split())
sum=a+b
print(sum,"\n")

it is not working anyone please help me

Why put "\n" again when print will automatically add a new line at the end?

It does not working
Code is here
try:
x = input(“What is your name”)
print(x)
except:
pass

In output only print the line “What is your name”. It can’t take input from user

Write your input on the section “Custom Input” and then click “Run”.

1 Like

Thanks @chandan2495 i had the same error and this answer helped.

Can u plz share the codechef link for this questions i might have an alternative solution