[Tutor] TypeError: generatePersonID() takes exactly 1 argument (0 given)

Joel Goldstick joel.goldstick at gmail.com
Thu Nov 14 18:21:11 CET 2013


On Thu, Nov 14, 2013 at 10:54 AM, Thabile Rampa <thabilerampa at gmail.com> wrote:
> Hi,
>
> So I'm learning how to define my own functions, and in an exercise I was
> given, I get this error:
>
> Traceback (most recent call last):
>   File "X:/X/xxx/Xxxxx/function_practice.py", line 36, in <module>
>     main ()
>   File "X:/X/xxx/Xxxxx/function_practice.py/function_practice.py", line 34,
> in main
>     generatePersonID ()
> TypeError: generatePersonID() takes exactly 1 argument (0 given)
>
> Here is the code:
>
> def getUserInput():
>     """
>     Get input from the user, i.e fullname, grossSalary, costs.
>     Returns: fullName, grossSalary, costs
>     """
>
>     grossSalary =None ;
>     costs =None
>     fullName=""
>
>     while not fullName:
>
>         fullName = raw_input ("First and Last Names: ")
>
>     while not grossSalary:
>         #TODO
>         grossSalary = int (raw_input ("Annual Gross Salary: "))
>
>     while not costs:
>                 #TODO
>         costs = int(raw_input ("Yearly costs: "))
>
>     return fullName, grossSalary, costs
>
> def generatePersonID (fullName):
>     """generates unique ID"""
>     global id
>     id = (fullName) + 1
>     personID = str (id) + fullName
>     return personID
>
> def main ():
>     getUserInput ()
>     generatePersonID ()
>
> main ()
>
> raw_input ("Press the enter key to exit.")
>
> Regards,
> Tab
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

You defined generatePersonID to take the parameter fullName, but when
you call it, you don't pass a value.

See what happens if you change the last line of main() to this:
generatePersonID("PersonID")

-- 
Joel Goldstick
http://joelgoldstick.com


More information about the Tutor mailing list