def postcode_in_state(self, state_abbr: Optional[str] = None) -> str:
        """
        :returns: A random postcode within the provided state

        :param state: A state

        Example: 55100
        https://en.wikipedia.org/wiki/Postal_codes_in_Malaysia#States
        """

        if state_abbr is None:
            state_abbr = self.random_element(self.states.keys())

        try:
            # some states have multiple ranges so first pick one, then generate a random postcode
            range = self.generator.random.choice(self.states_postcode[state_abbr])
            postcode = "%d" % (self.generator.random.randint(*range))

            # zero left pad up until desired length (some have length 3 or 4)
            target_postcode_len = 5
            current_postcode_len = len(postcode)
            if current_postcode_len < target_postcode_len:
                pad = target_postcode_len - current_postcode_len
                postcode = f"{'0'*pad}{postcode}"

            return postcode
        except KeyError as e:
            raise KeyError("State Abbreviation not found in list") from e

        :returns: A random postcode within the provided state

        :param state: A state

        Example: 55100
        https://en.wikipedia.org/wiki/Postal_codes_in_Malaysia#States
        
faker/providers/address/en_MS/__init__.py