Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to print variable name?
#9
(Oct-20-2019, 02:01 PM)newbieAuggie2019 Wrote: Hi!

I'm not sure what you want. Could it be this???:

def length(x,y):
    print(f"The length of 'ab' is {x + y}.")

a = 5
b = 3
length(a, b)
that produces the following output:
Output:
The length of 'ab' is 8.
All the best,

What if I call it with:

length(c, d)
length(e,f)
Every time the result should be
The length of 'ab' is ...
While it has to be:

The length of 'cd' is ...
and

The length of 'ef' is ...
Reply


Messages In This Thread
How to print variable name? - by mayadob - Oct-18-2019, 10:11 AM
RE: How to print variable name? - by mayadob - Oct-18-2019, 10:33 AM
RE: How to print variable name? - by Larz60+ - Oct-18-2019, 11:08 AM
RE: How to print variable name? - by mayadob - Oct-18-2019, 11:23 AM
RE: How to print variable name? - by perfringo - Oct-18-2019, 12:29 PM
RE: How to print variable name? - by mayadob - Oct-20-2019, 01:10 PM
RE: How to print variable name? - by mayadob - Oct-20-2019, 04:07 PM
RE: How to print variable name? - by mayadob - Oct-18-2019, 02:28 PM
RE: How to print variable name? - by ichabod801 - Oct-20-2019, 05:45 PM
RE: How to print variable name? - by ichabod801 - Oct-21-2019, 01:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print variable without '' and spaces arnonim 1 793 Jan-30-2023, 05:23 PM
Last Post: deanhystad
  Problem with print variable in print.cell (fpdf) muconi 0 721 Dec-25-2022, 02:24 PM
Last Post: muconi
  Remove a space between a string and variable in print sie 5 1,955 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  Can you print a string variable to printer hammer 2 2,102 Apr-30-2022, 11:48 PM
Last Post: hammer
  Print variable between " paulo79 5 1,819 Mar-11-2022, 05:16 PM
Last Post: deanhystad
  When I print a key from dict it prints it but when I try to assign it to a variable I stefanvelikov 3 2,456 Nov-27-2020, 01:29 PM
Last Post: stefanvelikov
  Print variable values from a list of variables xnightwingx 3 2,734 Sep-01-2020, 02:56 PM
Last Post: deanhystad
  Print part of a variable rs74 4 2,702 Jul-27-2020, 04:39 PM
Last Post: rs74
  How do I print a returned variable calculated in another function? RedSkeleton007 3 3,671 Jul-10-2018, 12:10 PM
Last Post: buran
  Empty variable when using print before readline fstefanov 3 3,775 Oct-23-2017, 02:22 AM
Last Post: fstefanov

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020