Python Forum

Full Version: Getting error message for indentation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HI

i am getting an error for incorrect indentation but can not find the error.
##30/04/19
##
##increment attributes through method

class Ereader():
	"""A class to represent an ereader"""

	def __init__ (self, make, model, backlight, battery, screentype):
		"""initialise the atributes to represent an ererader"""
		self.make=make
		self.modle=model
		self.backlight=backlight
		self.battery=battery
		self.screentype=screentype 
		self.libararycount=0

	def get_ereader_name(self):
		"""return a formatted description for our ereader"""
		long_name = self.make + " - " + self.model + " - " +self.backlight + " - " + self.battery + " - " + self.screentype
		return long_name.title()

	def read_libarary_count(self):
		print("You Have " + str(self.libararycount) + " books in your libarary")


	def update_laibary_count(self, ebook_count):
		"""set the libary count"""
		self.libararycount=ebook_count

	def increment_libary_count(self, purchased_ebooks):
		"""add new ebboks to libary count"""
		self.libararycount+=purchased_ebooks




		
class Screen():
	"""create a class to model the screen of a kindle fire"""

	def__init__ (self, screen_resoloution='1280*800')
		"""initialise the screens attributes"""

		self.screen_resoloution=screen_resoloution

	def describe_screen(self):
		"""print out some marketing information about the kindle fire"""
		##this tells the child class to call the features from the parent class
		print("fire HD 8 features a wide screen " + self.screen_resoloution+ " HD screen.")





class Kindlefire(Ereader):
	"""represents aspects of an ereader specific to a kindle fire
	then initialise atributes specific to a kindle fire"""

	def __init__ (self, make, modle, backlight, battery, screentype):
		"""initialize attributes for the kindle fire"""
		super().__init__(make, modle, backlight, battery, screentype)
		self.firescreen=Screen


my_kindle_fire = Kindlefire('amazon', 'kindlefire', 'backlight', '12 hour battrey life', 'colorscreen')
print(my_kindle_fire.get_ereader_name())


my_kindle_fire.firescreen.describe_screen()
class Screen():
    """create a class to model the screen of a kindle fire"""
 
    def__init__ (self, screen_resoloution='1280*800')
#      ^ no space after def                          ^ no : at the end
i am still getting indentation error on line 42.
##30/04/19
##
##increment atrabutes through method

class Ereader():
	"""A class to represent an ereader"""

	def __init__ (self, make, modle, backlight, battery, screentype):
		"""inatilase the atributes to represent an ererader"""
		self.make=make
		self.modle=modle
		self.backlight=backlight
		self.battery=battery
		self.screentype=screentype 
		self.libararycount=0

	def get_ereader_name(self):
		"""return a formatted description for our ereader"""
		long_name = self.make + " - " + self.modle + " - " +self.backlight + " - " + self.battery + " - " + self.screentype
		return long_name.title()

	def read_libarary_count(self):
		print("You Have " + str(self.libararycount) + " books in your libarary")


	def update_laibary_count(self, ebook_count):
		"""set the libary count"""
		self.libararycount=ebook_count

	def increment_libary_count(self, purchesed_ebooks):
		"""add new ebboks to libary count"""
		self.libararycount+=purchesed_ebooks




		
class Screen():
	"""create a class to model the screen of a kindle fire"""

	def__init__(self, screen_resoloution='1280*800')
		"""initialize the screens attributes"""

		self.screen_resoloution=screen_resoloution

	def describe_screen(self):
		"""print out some markjeting information about the kindle fire"""
		##this tells the child class to call the fetures from the parent class
		print("fire HD 8 fetures a wide screen " + self.screen_resoloution+ " HD screen.")





class Kindlefire(Ereader):
	"""represents aspects of an ereader spicific to a kindle fire
	then initilaise atributes spicific to a kindle fire"""

	def__init__(self, make, modle, backlight, battery, screentype):
		"""initlize atributes for the kindle fire"""
		super().__init__(make, modle, backlight, battery, screentype)
		self.firescreen=Screen


my_kindle_fire = Kindlefire('amazon', 'kindlefire', 'backlight', '12 hour battrey life', 'colorscreen')
print(my_kindle_fire.get_ereader_name())


my_kindle_fire.firescreen.describe_screen()
Output:
line 42 """initialize the screens attributes""" ^ IndentationError: unexpected indent
You didn't fix the errors i pointed out.
sorry. my mistake..Thank You
No worries, at least you improved on how you reported the error by giving a full trace back Dance