Skip to content

Instantly share code, notes, and snippets.

@ycui1
Created November 6, 2021 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycui1/3f80667712ed020d9c2231c0e924e02d to your computer and use it in GitHub Desktop.
Save ycui1/3f80667712ed020d9c2231c0e924e02d to your computer and use it in GitHub Desktop.
>>> 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