<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, name_or_index, word):
 		""" 		Write a word in the Register with the name ``name_or_index`` or with the index ``name_or_index``. 		``name_or_index`` hat to be either ``str`` or ``int``. If the type of ``name_or_index`` 		is wrong an AttributeError will be raised. 		If there is no Register with the specified name or index, a NameError will be raised. 		"""

		if(isinstance(name_or_index, str)):
			if(name_or_index in self.registers_by_name):
				self.registers_by_name[name_or_index].write(word)
			else:
				raise NameError("No Register with name '{}'".format(name_or_index))
		elif( isinstance(name_or_index, int)):
			if(name_or_index < len(self.registers_by_index)):
				self.registers_by_index[name_or_index].write(word)
			else:
				raise NameError("No Register with index '{}'".format(name_or_index))
		else:
			raise AttributeError("name_or_index has to be `str` or `int`, but is {}".format(type(name_or_index)))