Sep-02-2023, 05:10 PM
Hi,
Quite new topython and this is a problem I have spent 1.5 hrs trying to work out, for context I wanted to define a function that would create a file named based on the variable input to the function. I have come across the issue that I am able to return the variable's value or the function define, but am not able to print the variable I am putting into the function.
I have given a brief example of what I mean- I would want the function to print 'a' if "function(a)" is ran. Thanks in advance, I'm sure there is a easy solution but searching forums/google has not got me beyond the .split('=')
Quite new topython and this is a problem I have spent 1.5 hrs trying to work out, for context I wanted to define a function that would create a file named based on the variable input to the function. I have come across the issue that I am able to return the variable's value or the function define, but am not able to print the variable I am putting into the function.
I have given a brief example of what I mean- I would want the function to print 'a' if "function(a)" is ran. Thanks in advance, I'm sure there is a easy solution but searching forums/google has not got me beyond the .split('=')
a = 3 def function (input): print(f"{input}") print(f"{input=}".split('=')[0]) function(a)