how to calculate chi square in python

from scipy.stats import chisquare
stat, p = chisquare(mylist)

Here is what the above code is Doing:
1. We’re using the chisquare function from the scipy.stats library to perform the chi-square test.
2. We’re passing in mylist as the first argument.
3. We’re storing the results of the chi-square test in two variables: stat and p.
4. The stat variable contains the chi-square statistic.
5. The p variable contains the p-value.