0

I want print paramater's name in a python function

First, a variable is assigned a value.Then, pass the variable to a function. Last,I want to print str(variable) inner the function.

varibale = 1234

def f(x):
  print(....)
  return

f(varibale)

Expected output is print out the 'varibale' whatever variable is. if a = 1 ==> f(x), expected output is 'a';if b = 2 ==> f(x), expected output is 'b'.....

ForceBru
  • 43,482
  • 10
  • 63
  • 98
Todd
  • 55
  • 1
  • 5

1 Answers1

0

Why do you want to print out the value using a function?

If you know the name of the variable, you can simply write your requested function output yourself by just putting 'variable'

So in your example: instead of using f(x), just use print('x')