Why this error happens?

ERROR:
Traceback (most recent call last):
File “script.py”, line 44, in
k = int(input())
EOFError: EOF when reading a line


MY CODE


class TreeNode:

def __init__(self,data,left=None,right=None):

    self.data = data

    self.left = left

    self.right = right

def setLeft(self,val):

    self.left = TreeNode(val)

def setRight(self,val):

    self.right = TreeNode(val)

def insert(root,val):

if root.data == None:

    root.data = val

queue = [root]

n = 1

while(n>=0):

    k = queue.pop()

    n-=1

    if root.left:

        queue.append(root.left)

        n+=1

    else:

        root.left = TreeNode(val)

        break

    if root.right:

        queue.append(root.right)

        n+=1

    else:

        root.right = TreeNode(val)

        break

return root

def createTreeFromArray(arr):

root = TreeNode(arr[0])

for i in range(1,len(arr)):

    insert(root,arr[i])

return root

if name==“main”:

k = int(input())

for i in range(k):

    myarr = list(map(int,input().split()))

    x = int(input())

    root = createTreeFromArray(myarr)

    count = 0

    def subTreesWithGivenSum(root,x):

        if root:

            leftval = 0

            rightval = 0

            if root.left:

                leftval = root.left.data

            if root.right:

                rightval = root.right.data

            if root.data+rightval+leftval == x:

                count+=1

            subTreesWithGivenSum(root.left,x)

            subTreesWithGivenSum(root.right,x)

        else:

            return

    print(count)

Hello @hemu1999, are you taking the input while compiling this ?? You need to put the input in the input bar in order to compile your code.

hi @hemu1999 you havent answered the above question, please tell

I got the error while submitting!

Okay, my question is that while compiling or running did you put the input inside the input box or not ?? This error seems to be related to the input

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.