I just started Python.
import numpy as np
import matplotlib.pyplot asplt
x = np.linspace(0,2*np.pi,50)
def(x):
np.sin(x)
plt.plot(x,f(x),label='y')
plt.show()
where
ValueError: x, y, and format string must not be None
appears.
What does this error mean and what is the cause?
The reason is that the function f(x)
has not returned the value (must be return np.sin(x)
.
In addition, if Python does not explicitly return
, the return value of the function is always None
, which causes ValueError to display the message must not be None
(you must not specify a value of = None).
This post contains comments from @metropolis and @PicoSushi's comment.
© 2024 OneMinuteCode. All rights reserved.