attribute error in python

0 votes
i kept getting attribute error in my code. here is my code below

class Employee:

    raise_amt = 1.04

    def __init__(self, first, last, pay):

        self.first = first

        self.last = last

        self.email = first +''+ last + '@company.com'

        self.pay = pay

        def fullname(self):

            return '{} {}'.format(self.first, self.last)

        def apply_raise(self):

            self.pay = int(self.pay * self.raise_amt)

class Developers(Employee):

    pass

dev_1 = Employee ('Nwankwo','Fortune',70000)

dev_2 = Employee ('Test','User', 50000)

#print(dev_1.email)

#print(dev_2.email)

dev_1.apply_raise()

print(dev_1.pay)
Dec 23, 2019 in Python by anonymous
• 120 points
• 2,214 views
Hey!

Can you please post the entire error log?

Thanks

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
There is just a indentation issue in your code

Simply align the two def apply_raise and def fullname to the same indentation as def __init__() and it works fine
answered Jan 21, 2021 by Vaibhav Yadav

edited Mar 5, 2025

Related Questions In Python

0 votes
1 answer

what is attribute error in python?

import pandas df = pd.read_csv('filename') it will give attribute ...READ MORE

answered Mar 27, 2019 in Python by Mohammad
• 3,230 points
• 2,307 views
0 votes
1 answer

Python error "'str' object has no attribute 'turtle' in Python turtle"

There is a syntax error. Change the ...READ MORE

answered Jul 9, 2019 in Python by Pallavi
• 9,246 views
+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

answered Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
• 8,946 views
0 votes
2 answers

Indentation Error in Python

Use tabs instead of spaces. This is ...READ MORE

answered Feb 15, 2019 in Python by Shashank
• 1,370 points
• 2,616 views
+1 vote
1 answer

How to print an error in Python?

For Python 2.6 and later and Python ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 58,020 points
• 2,683 views
0 votes
1 answer

Key error in Python

A KeyError occurs when the Key doesn't ...READ MORE

answered Sep 20, 2018 in Python by SDeb
• 13,300 points
• 2,678 views
0 votes
1 answer

How can I print an Error in Python?

For Python 2.6 and later and Python ...READ MORE

answered Oct 12, 2018 in Python by aryya
• 7,460 points
• 2,081 views
+2 votes
10 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,560 points
• 428,912 views
0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,560 points
• 11,749 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP