Python: TypeError: takes exactly 1 argument (2 given)

后端 未结 1 740
难免孤独
难免孤独 2020-12-19 18:25

I\'m currently using singpath.com to practice my python, but I face an issue with a problem:

The expected result is:

>>>CurryPuff(3) 
3.60 
         


        
相关标签:
1条回答
  • 2020-12-19 18:41

    You can't call a function with 1 argument if it expects 2, as CurryPuff() does. However, you can define a default argument that is used if no argument is passed:

    def CurryPuff(x, typePuff=None):
        if typePuff is None:
           # and so on...
    

    You can do this with any value for any argument. You may only omit arguments if a default value is defined.

    0 讨论(0)
提交回复
热议问题