can only concatenate str (not "tuple") to str

3.5k Views Asked by At
def chek_stationary(x):
    result=adfuller(x)
    label=['ADF statestic test','p value','num of legs','num of observation']
    for value,label in zip(result,label):
        print(label + ":" + result)
    if result[1] <= 0.05 :
        print ('there is evedincee null hypothesis')
        print('which means there is no root here ')
        print ('and its  stationary ')
    else :
        print ('there isnot evedence and there is root and its nun stationrary')

Whenever I tried this function, I got this error: "can only concatenate str (not "tuple") to str"

What should I do ?

1

There are 1 best solutions below

0
On BEST ANSWER

Example of your situation:

str_var = 'aaa'
tuple_var = ('b','B')
print(str_var  + ":" +  tuple_var)

Result with the same error thrown: TypeError: can only concatenate str (not "tuple") to str

Fix: - just add str() function before.

str_var = 'aaa'
tuple_var = ('b','B')
print(str_var  + ":" +  str(tuple_var))

Result without error: aaa:('b', 'B')