I have defined a function string_adder that receives two arguments and returns a concatenated version of both arguments.
JavaScript
x
7
1
def string_adder(a,b):
2
bac = a + " " + b
3
return bac
4
5
string_adder("boy","girl")
6
print (string_adder)
7
However, when I run the code, I get this error message:
<function string_adder at 0x10cf5bb90>
Any advice on what I’m doing wrong?
Advertisement
Answer
On the line string_adder("boy","girl")
you call the function but don’t do anything with what it returns. You need to change it to string_adder = string_adder("boy","girl")
, probably with a different variable name for ease of reading. You’d need to change the print line in that case too.