Created
May 22, 2024 07:27
-
-
Save 2tony2/d11c768b9161b9fcb75a48f9d6540319 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import TypeVar, List | |
| T = TypeVar('T') | |
| def duplicate(item: T) -> List[T]: | |
| return [item, item] | |
| # Usage examples | |
| print(duplicate(123)) # [123, 123] | |
| print(duplicate("Hello")) # ['Hello', 'Hello'] | |
| print(duplicate([1, 2, 3])) # [[1, 2, 3], [1, 2, 3]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment