I need to do some math operation in my code. I'm doing something like this:

kapaerror_list[i] = sqrt(4*((LDerror_list[i])**2)*((LDmean_list[i])**2) - (error_list[i])**2)

    print "%s\t%g\t%g\t%g\t%g" % (indexvalue_list[i],mean_list[i],kapa_list[i],LDmean_list[i],kapaerror_list[i])

but i'm getting the following error:


print "%s\t%g\t%g\t%g\t%g" % (indexvalue_list,mean_list,kapa_list,LDmean_list,kapaerror_list)
TypeError: float argument required


The funny thing to me is that when i erase sqrt and just writing:


kapaerror_list[i] = (4*((LDerror_list[i])**2)*((LDmean_list[i])**2) - (error_list[i])**2)

It doesn't give me any error.

I really appreciate your help.

Put all formats to %s and see the values, one of %g parameters is not float needed for scientific format number.

Or do

print [type(i) for i in (indexvalue_list[i], mean_list[i], kapa_list[i], LDmean_list[i], kapaerror_list[i])]

To see which type the values are.

You can also use **0.5 instead of sqrt().

Thanks a lot for the quick response. That solved the problem.
I really appreciate your help. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.