[Solved] How to print varible name in python [duplicate]


You could achieve a similar behaviour by using a dictionary and a for-loop iterating through it:

#!/usr/bin/env python3
# coding: utf-8

# define a dict with sample data
d = {'fruit': 13}

# print keys and values of sample dict
for key, val in d.items():
    print(key, val)

Output looks like:

fruit 13

2

solved How to print varible name in python [duplicate]