I have a user defined function in the code below. Is there a way for me to re-write it with different syntax where I don't use brackets around the variable I want but rather have the function as a method such as .printfunction. Is there a way using classes and methods to rewrite the function as a method rather than a user-defined function?
The desired output needs to be xY .
def printfunction(var2):
return "x" + var2
printfunction("Y")
def printfunction(var2):
return "x" + var2
#Desired Syntax
var1 = "x"
var1.printfunction("Y")