我无法将两个输出添加到def函数。
我尝试了很多方法,但是无论是对还是错,它总是只输出其中一种。
loan_True = True
loan_False = False
def message():
if loan_True == True:
print()
message = f"""\
Subject: Loan Application
Hello {Fn} {Ln}, {hurray}
"""
elif loan_False == False:
print()
message = f"""\
Subject: Loan Application
Hello {Fn} {Ln}, {sorry}
"""
return message
message()
Output of code that is correct and exactly what i want This is the email the code sends but its wrong. i want the output in the email to be the same exact in the first pic. 我希望输出是它分配的。
答案 0 :(得分:1)
我会提出类似的建议
def message(loan_allowed):
if loan_allowed:
return "hooray"
else
return "sorry"
即使用函数参数而不是全局变量。如果要在函数中使用变量,我会使用
def message(loan_allowed):
text = None
if loan_allowed:
text = "hooray"
else
text = "sorry"
return text
即首先在功能范围内进行设置。并使用与函数不同的名称。