Does my function right on python?

Posted by Ali Ismayilov on Stack Overflow See other posts from Stack Overflow or by Ali Ismayilov
Published on 2011-02-14T07:22:51Z Indexed on 2011/02/14 7:25 UTC
Read the original article Hit count: 212

Filed under:

Write a function which takes a string argument, and creates and returns an Employee object containing details of the employee specified by the string. The string should be assumed to have the format 12345 25000 Consultant Bart Simpson The first three items in the line will be the payroll number, salary and job title and the rest of the line will be the name. There will be no spaces in the job title but there may be one or more spaces in the name.

My function:

def __str__(self):

    return format(self.payroll, "d") + format(self.salary, "d") + ' ' \
          + self.jobtitle + self.name 

© Stack Overflow or respective owner

Related posts about python