“How to fix 'function call problem' in this question”Calling a function of a module by using its name (a string)How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?Calling an external command in PythonHow can I safely create a nested directory?Using global variables in a functionHow do I sort a dictionary by value?How to make a chain of function decorators?How do I list all files of a directory?

Are these reasonable traits for someone with autism?

Why does this if-statement combining assignment and an equality check return true?

Is there some hidden joke behind the "it's never lupus" running gag in House?

Is there a way to make it so the cursor is included when I prtscr key?

Is CD audio quality good enough?

Why does Mjolnir fall down in Age of Ultron but not in Endgame?

At what point in European history could a government build a printing press given a basic description?

What is quasi-aromaticity?

Simple function that simulates survey results based on sample size and probability

How to use Palladio font in text body but Computer Modern for Equations?

How strong are Wi-Fi signals?

Why does the 6502 have the BIT instruction?

Is real public IP Address hidden when using a system wide proxy in Windows 10?

Would jet fuel for an F-16 or F-35 be producible during WW2?

Employer asking for online access to bank account - Is this a scam?

What kind of metaphor is "trees in the wind"?

Should one buy new hardware after a system compromise?

Using credit/debit card details vs swiping a card in a payment (credit card) terminal

Popcorn is the only acceptable snack to consume while watching a movie

Image processing: Removal of two spots in fundus images

I think I may have violated academic integrity last year - what should I do?

What is memelemum?

Should breaking down something like a door be adjudicated as an attempt to beat its AC and HP, or as an ability check against a set DC?

Why is this Simple Puzzle impossible to solve?



“How to fix 'function call problem' in this question”


Calling a function of a module by using its name (a string)How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?Calling an external command in PythonHow can I safely create a nested directory?Using global variables in a functionHow do I sort a dictionary by value?How to make a chain of function decorators?How do I list all files of a directory?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0
















File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'




class ListNode:
def __init__(self,x):
self.val=x
self.next=None
class Solution:
def addTwoNumber(self,l1,l2):
head=l3=ListNode(0)
carry=0

while l1 or l2 or carry:
if l1:
carry+=l1.val
l1=l1.next
if l2:
carry+=l2.val
l2=l2.next

l3.val=carry%10
carry=carry//10

if l1 or l2 or carry:
l3.next=ListNode(0)
l3=l3.next
print(head)
return head

l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)









share|improve this question
























  • File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in <module> class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'

    – shubham raj
    Mar 24 at 5:52

















0
















File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'




class ListNode:
def __init__(self,x):
self.val=x
self.next=None
class Solution:
def addTwoNumber(self,l1,l2):
head=l3=ListNode(0)
carry=0

while l1 or l2 or carry:
if l1:
carry+=l1.val
l1=l1.next
if l2:
carry+=l2.val
l2=l2.next

l3.val=carry%10
carry=carry//10

if l1 or l2 or carry:
l3.next=ListNode(0)
l3=l3.next
print(head)
return head

l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)









share|improve this question
























  • File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in <module> class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'

    – shubham raj
    Mar 24 at 5:52













0












0








0









File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'




class ListNode:
def __init__(self,x):
self.val=x
self.next=None
class Solution:
def addTwoNumber(self,l1,l2):
head=l3=ListNode(0)
carry=0

while l1 or l2 or carry:
if l1:
carry+=l1.val
l1=l1.next
if l2:
carry+=l2.val
l2=l2.next

l3.val=carry%10
carry=carry//10

if l1 or l2 or carry:
l3.next=ListNode(0)
l3=l3.next
print(head)
return head

l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)









share|improve this question

















File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'




class ListNode:
def __init__(self,x):
self.val=x
self.next=None
class Solution:
def addTwoNumber(self,l1,l2):
head=l3=ListNode(0)
carry=0

while l1 or l2 or carry:
if l1:
carry+=l1.val
l1=l1.next
if l2:
carry+=l2.val
l2=l2.next

l3.val=carry%10
carry=carry//10

if l1 or l2 or carry:
l3.next=ListNode(0)
l3=l3.next
print(head)
return head

l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)






python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 5:54









Mikhail Vladimirov

11.4k12631




11.4k12631










asked Mar 24 at 5:50









shubham rajshubham raj

11




11












  • File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in <module> class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'

    – shubham raj
    Mar 24 at 5:52

















  • File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in <module> class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'

    – shubham raj
    Mar 24 at 5:52
















File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in <module> class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'

– shubham raj
Mar 24 at 5:52





File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 5, in <module> class Solution: File "/home/shubham/PycharmProjects/LeetCode/AddTwoLinkedList.py", line 35, in Solution addTwoNumber(l1, l2) TypeError: addTwoNumber() missing 1 required positional argument: 'l2'

– shubham raj
Mar 24 at 5:52












2 Answers
2






active

oldest

votes


















2














I see a few issues with your code.



First of all, Python is whitespace based language.



As a result, your chunk of code



l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)


is actually in the body of your Solution class.



This needs to be pulled out to the global scope of the file. To make this post shorter, I've removed the body of your code.



class Solution:
# put your code in here

s = Solution()
l1 = ListNode(2)
l2 = ListNode(6)
answer = s.addTwoNumber(l1, l2)


Notice, how I also created an instance of Solution. We need to do this because addTwoNumber is an instance method of Solution



Then you run that file with python your_filename.py



You are getting TypeError: addTwoNumber() missing 1 required positional argument: 'l2' because Python automatically supplies the self variable which references an instance of an object when you invoke an instance method.



However, you have not allowed Python to supply that self because it is currently being called like it is a static method so it fills the arguments left to right. Which means, it is passed "self" and "l1" with l1 and l2 respectively but your function expects 3 arguments.






share|improve this answer

























  • dear as u said ,i done.but i'm not getting output and also there is not showing any error

    – shubham raj
    Mar 24 at 7:39












  • this code is already run on LeetCode, but now i want to print it in proper way in IDE ,so can u help me out,if u can???

    – shubham raj
    Mar 24 at 7:46


















1














Function addTwoNumber is a member function, so it needs value of self to be passed either as addTwoNumber(selfValue, l1, l2) or as selfValue.addTwoNumber(l1, l2).



Just replace selfValue whith whatever value you want to pass as self parameter.






share|improve this answer

























  • its not working!!!

    – shubham raj
    Mar 25 at 6:17











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321085%2fhow-to-fix-function-call-problem-in-this-question%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I see a few issues with your code.



First of all, Python is whitespace based language.



As a result, your chunk of code



l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)


is actually in the body of your Solution class.



This needs to be pulled out to the global scope of the file. To make this post shorter, I've removed the body of your code.



class Solution:
# put your code in here

s = Solution()
l1 = ListNode(2)
l2 = ListNode(6)
answer = s.addTwoNumber(l1, l2)


Notice, how I also created an instance of Solution. We need to do this because addTwoNumber is an instance method of Solution



Then you run that file with python your_filename.py



You are getting TypeError: addTwoNumber() missing 1 required positional argument: 'l2' because Python automatically supplies the self variable which references an instance of an object when you invoke an instance method.



However, you have not allowed Python to supply that self because it is currently being called like it is a static method so it fills the arguments left to right. Which means, it is passed "self" and "l1" with l1 and l2 respectively but your function expects 3 arguments.






share|improve this answer

























  • dear as u said ,i done.but i'm not getting output and also there is not showing any error

    – shubham raj
    Mar 24 at 7:39












  • this code is already run on LeetCode, but now i want to print it in proper way in IDE ,so can u help me out,if u can???

    – shubham raj
    Mar 24 at 7:46















2














I see a few issues with your code.



First of all, Python is whitespace based language.



As a result, your chunk of code



l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)


is actually in the body of your Solution class.



This needs to be pulled out to the global scope of the file. To make this post shorter, I've removed the body of your code.



class Solution:
# put your code in here

s = Solution()
l1 = ListNode(2)
l2 = ListNode(6)
answer = s.addTwoNumber(l1, l2)


Notice, how I also created an instance of Solution. We need to do this because addTwoNumber is an instance method of Solution



Then you run that file with python your_filename.py



You are getting TypeError: addTwoNumber() missing 1 required positional argument: 'l2' because Python automatically supplies the self variable which references an instance of an object when you invoke an instance method.



However, you have not allowed Python to supply that self because it is currently being called like it is a static method so it fills the arguments left to right. Which means, it is passed "self" and "l1" with l1 and l2 respectively but your function expects 3 arguments.






share|improve this answer

























  • dear as u said ,i done.but i'm not getting output and also there is not showing any error

    – shubham raj
    Mar 24 at 7:39












  • this code is already run on LeetCode, but now i want to print it in proper way in IDE ,so can u help me out,if u can???

    – shubham raj
    Mar 24 at 7:46













2












2








2







I see a few issues with your code.



First of all, Python is whitespace based language.



As a result, your chunk of code



l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)


is actually in the body of your Solution class.



This needs to be pulled out to the global scope of the file. To make this post shorter, I've removed the body of your code.



class Solution:
# put your code in here

s = Solution()
l1 = ListNode(2)
l2 = ListNode(6)
answer = s.addTwoNumber(l1, l2)


Notice, how I also created an instance of Solution. We need to do this because addTwoNumber is an instance method of Solution



Then you run that file with python your_filename.py



You are getting TypeError: addTwoNumber() missing 1 required positional argument: 'l2' because Python automatically supplies the self variable which references an instance of an object when you invoke an instance method.



However, you have not allowed Python to supply that self because it is currently being called like it is a static method so it fills the arguments left to right. Which means, it is passed "self" and "l1" with l1 and l2 respectively but your function expects 3 arguments.






share|improve this answer















I see a few issues with your code.



First of all, Python is whitespace based language.



As a result, your chunk of code



l1 = ListNode(2)
l1 = ListNode(4)
l1 = ListNode(3)
l2 = ListNode(5)
l2 = ListNode(6)
l2 = ListNode(4)
addTwoNumber(l1, l2)


is actually in the body of your Solution class.



This needs to be pulled out to the global scope of the file. To make this post shorter, I've removed the body of your code.



class Solution:
# put your code in here

s = Solution()
l1 = ListNode(2)
l2 = ListNode(6)
answer = s.addTwoNumber(l1, l2)


Notice, how I also created an instance of Solution. We need to do this because addTwoNumber is an instance method of Solution



Then you run that file with python your_filename.py



You are getting TypeError: addTwoNumber() missing 1 required positional argument: 'l2' because Python automatically supplies the self variable which references an instance of an object when you invoke an instance method.



However, you have not allowed Python to supply that self because it is currently being called like it is a static method so it fills the arguments left to right. Which means, it is passed "self" and "l1" with l1 and l2 respectively but your function expects 3 arguments.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 at 6:07

























answered Mar 24 at 6:02









SkamSkam

2,53221427




2,53221427












  • dear as u said ,i done.but i'm not getting output and also there is not showing any error

    – shubham raj
    Mar 24 at 7:39












  • this code is already run on LeetCode, but now i want to print it in proper way in IDE ,so can u help me out,if u can???

    – shubham raj
    Mar 24 at 7:46

















  • dear as u said ,i done.but i'm not getting output and also there is not showing any error

    – shubham raj
    Mar 24 at 7:39












  • this code is already run on LeetCode, but now i want to print it in proper way in IDE ,so can u help me out,if u can???

    – shubham raj
    Mar 24 at 7:46
















dear as u said ,i done.but i'm not getting output and also there is not showing any error

– shubham raj
Mar 24 at 7:39






dear as u said ,i done.but i'm not getting output and also there is not showing any error

– shubham raj
Mar 24 at 7:39














this code is already run on LeetCode, but now i want to print it in proper way in IDE ,so can u help me out,if u can???

– shubham raj
Mar 24 at 7:46





this code is already run on LeetCode, but now i want to print it in proper way in IDE ,so can u help me out,if u can???

– shubham raj
Mar 24 at 7:46













1














Function addTwoNumber is a member function, so it needs value of self to be passed either as addTwoNumber(selfValue, l1, l2) or as selfValue.addTwoNumber(l1, l2).



Just replace selfValue whith whatever value you want to pass as self parameter.






share|improve this answer

























  • its not working!!!

    – shubham raj
    Mar 25 at 6:17















1














Function addTwoNumber is a member function, so it needs value of self to be passed either as addTwoNumber(selfValue, l1, l2) or as selfValue.addTwoNumber(l1, l2).



Just replace selfValue whith whatever value you want to pass as self parameter.






share|improve this answer

























  • its not working!!!

    – shubham raj
    Mar 25 at 6:17













1












1








1







Function addTwoNumber is a member function, so it needs value of self to be passed either as addTwoNumber(selfValue, l1, l2) or as selfValue.addTwoNumber(l1, l2).



Just replace selfValue whith whatever value you want to pass as self parameter.






share|improve this answer















Function addTwoNumber is a member function, so it needs value of self to be passed either as addTwoNumber(selfValue, l1, l2) or as selfValue.addTwoNumber(l1, l2).



Just replace selfValue whith whatever value you want to pass as self parameter.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 25 at 6:20

























answered Mar 24 at 6:01









Mikhail VladimirovMikhail Vladimirov

11.4k12631




11.4k12631












  • its not working!!!

    – shubham raj
    Mar 25 at 6:17

















  • its not working!!!

    – shubham raj
    Mar 25 at 6:17
















its not working!!!

– shubham raj
Mar 25 at 6:17





its not working!!!

– shubham raj
Mar 25 at 6:17

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321085%2fhow-to-fix-function-call-problem-in-this-question%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현