Issue with this code : PYTHON

What’s issue with my code ?

Same question on leetcode in order to avoid input output

class Solution:
    # @param head, a RandomListNode
    # @return a RandomListNode
    def copyRandomList(self, head):
        if head is None:
            return head

        temp=head
        while temp:
            x=Node(temp.val)
            x.next=temp.next
            temp.next=x
            temp=x.next
        
        temp=head
        while temp:
            a=temp
            a_dash=a.next
            d=a.random
            if d:
                d_dash=d.next
                a_dash.random=d_dash
            temp=temp.next.next
            
        
        new_head=head.next
        temp=head
        temp_dash=head.next
        while temp and temp_dash:
            n=temp_dash.next
            if n:
                n_dash=n.next
                temp_dash.next=n_dash
                temp_dash=n_dash
            temp.next=n
            
            temp=n
            
        return new_head

your code is accepted

on leetcode, but not on your portal

In hacker block you have to write complete code
not only the function

oh!
can you provide template code for all questions which takes the input and creates the data structure as required in question like leetcode,etc as it’s time-consuming and of no use?

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.

can you send template code for i/p-o/p ?
i’m in hurry to complete all questions (like leetcode, want to just fill function for desired output.)

I don’t have such template

You have to write complete code

Hello @ritvikagrawal1, one thing you can do is to make one template for input-output and use that all over the questions. You can get the template from leetcode or hackerrank function based questions. Once you get that template define every kind of func that you required the most and use that in place of need.

how to get template from leetcode?
i’m facing issues for template in questions like this

Sorry, I think we can’t access that anymore it’s become the part of the premium pack. Although while running you will get a button known as debugger from where we can check that. So now you can refer it from other online coding sites or create the one for yourself.