When using a list as a parameter in a recursive function, If I add items to that list using + operator everything works as expected. But if I am using the += operator the function return value changes. Why does it happens? aren't += has the same meaning as +?
def rec(str_bucket,s,temp=[]):
if (''.join(temp))==s:
return True
if not str_bucket:
return False
**temp +=[str_bucket[0][0]]** *# instead of: temp = temp+[str_bucket[0][0]]*
a =rec(str_bucket[1:],s,temp)
temp = temp[:-1]+[str_bucket[0][1]]
b =rec(str_bucket[1:],s,temp)
temp = temp[:-1]
c = rec(str_bucket[1:],s,temp)
return a or b or c