Passing a string to a function

In the following code,

basic_text = """
SystemName      water
SystemLabel     water
\n"""

def basic(basic_text:str):
    siesta = basic_text
    siesta += "#\n# Definition of Atomic Species\n#\n"
    siesta += "#\n# Atoms\n#\n"
    siesta += "LatticeConstant    \n"
    print(siesta)

I am hoping that the following gets printed

SystemName      water
SystemLabel     water
Definition of Atomic Species
Atoms
LatticeConstant

Instead, I get blank. Any hints would be appreciated.

Thanks,
Vahid

You pass a value to a function when you call it.

That code defines function, but doesn’t call it.

To call it and pass basic_text, you would need to add basic(basic_text).

Thank you Matthew for your help. I modified the code so it reads

basic_text = """
SystemName      water
SystemLabel     water
\n"""


def basic(basic_text:str):
    siesta = basic_text
    siesta += "#\n# Definition of Atomic Species\n#\n"
    siesta += "#\n# Atoms\n#\n"
    siesta += "LatticeConstant      1.00 Ang\n"

basic(basic_text)
print(basic_text)

It prints the string basic_text. However, when I try to print(siesta), which is basic_text+three more lines, I get “NameError: name ‘siesta’ is not defined”. Is there a way to print all 5 lines, i.e., siesta?
Thanks

siesta is a local variable inside basic. You can’t get it from outside that function.

Maybe what you want is to return the value of siesta.

If that’s the case, then put:

    return siesta

at the end of basic to return the value and then assign the result that was returned to a variable called siesta outside the function with:

siesta = basic(basic_text)

That is exactly what I needed. Thank you for your help.
Vahid