In [1]:
import numpy as np

In [5]:
with open('test.txt', 'w') as f:
    x = np.random.randint(51, size=1000)
    for i in range(2):
        print(np.histogram(x, bins=30.shape)
        np.savetxt(f,np.histogram(x, bins=30)[i].reshape(1,-1))
        f.write("\n")


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-fffcef431a79> in <module>()
      2     x = np.random.randint(51, size=1000)
      3     for i in range(2):
----> 4         print(np.histogram(x, bins=30).shape)
      5         np.savetxt(f,np.histogram(x, bins=30)[i].reshape(1,-1))
      6         f.write("\n")

AttributeError: 'tuple' object has no attribute 'shape'

In [ ]: