Python Tricks

Print variable name and value

# Declaring a variable
my_colors = {1:'RED', 2:'BLUE', 3:'BLACK'}

# Showing in console the variable name and it's value
print(f'My dictionary has: {my_colors = }')

Output

>>> My dictionary has: my_colors = {1: 'RED', 2: 'BLUE', 3: 'BLACK'}

Leave a Reply

Your email address will not be published. Required fields are marked *