Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print a variable's name

Tags:

People also ask

Can you print the name of a variable?

So yes, you can create a variable called print and even replace the default function in Python 3.

How do you print a variable name in a statement in Python?

Using f-strings in Python to print variables is the most commonly used method and I would personally recommend using this method. In this method, an 'f' is placed before the opening quotation mark of a string. Braces {} are placed around the names of variables that you are looking to print.

How do I print a list name in Python?

Convert a list to a string for display : If it is a list of strings we can simply join them using join() function, but if the list contains integers then convert it into string and then use join() function to join them to a string and print the string.


I might be bad at googling as I couldn't find the answer to below question:

Sub TEST()
Dim sthstring as string
sthstring = "Hello World"
end sub

While we all know it's easy to use msgbox to print "Hello world", is it possible to print out the variable's name (which in this case, "sthstring") and how?

EDIT: please do not provide with answer such as:

Dim someotherstring as string  
someotherstring = "sthstring"

as I meant to find a way to print the 'name' of the variable, thanks