> For the complete documentation index, see [llms.txt](https://zcjian.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zcjian.gitbook.io/project/string/license-key-formatting.md).

# License Key Formatting

LeetCode 482

```python
class Solution:
    def licenseKeyFormatting(self, S, K):
        """
        :type S: str
        :type K: int
        :rtype: str
        """
        """
        Input: S = "2-5g-3-J", K = 2
        Output: "2-5G-3J"
        
        一些指令:
        str.upper()
        str.lower()
        str.isalnum()
        str.replace()
        str.join([iterable])
        """
        S = S.replace("-", "").upper()[::-1]
        return '-'.join(S[i:i+K] for i in range(0, len(S), K))[::-1]
```
