I want to create a function that checks if a string variable contains ".pdf" at the end and if not, to add it to the variable. When I run this, the output_name does not change. It works outside of a function just fine but I want to create a function so I don't repeat myself. Thanks for the help!
def check(output_name):
if ".pdf" not in output_name:
output_name += ".pdf"
else:
return None
output_name = "sample"
check(output_name)
print(output_name)