Created
November 6, 2021 16:16
-
-
Save ycui1/3f80667712ed020d9c2231c0e924e02d 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
>>> name = "Danny" | |
>>> age = 15 | |
>>> student = {"name": name} | |
>>> scores = [100, 99, 95] | |
>>> location = ('123 Main', 'NY') | |
>>> for item in (name, age, student, scores, location): | |
... print(f"{type(item)!s: <15}| repr: {repr(item): <20}| str: {str(item)}") | |
... | |
<class 'str'> | repr: 'Danny' | str: Danny | |
<class 'int'> | repr: 15 | str: 15 | |
<class 'dict'> | repr: {'name': 'Danny'} | str: {'name': 'Danny'} | |
<class 'list'> | repr: [100, 99, 95] | str: [100, 99, 95] | |
<class 'tuple'>| repr: ('123 Main', 'NY') | str: ('123 Main', 'NY') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment