Reputation: 19
import random
import matplotlib.pyplot as plt
a = 5
b = 10
c = 20
x = (print(random.randrange(a, b)))
y = (print(random.randrange(b, c)))
projectname = input('What is your project name?: ')
indep = input('What is your independent variable?: ')
dep = input('What is your dependent variable?: ')
plt.plot(x, y)
plt.xlabel(indep)
plt.ylabel(dep)
plt.title(projectname)
plt.show()
Here is the error code: "ValueError: x, y, and format string must not be None"
New to coding
Upvotes: 0
Views: 51
Reputation: 79
Take a look at these lines
x = (print(random.randrange(a, b)))
y = (print(random.randrange(b, c)))
The result of the print
function is None
. So the value stored in the x
and y
variables is None
and not the result of random.randrange
. So when you get to
plt.plot(x, y)
your actually saying plt.plot(None, None)
instead of
plt.plot(random.randrange(a, b), random.randrange(b, c))
If your wanting to show the user the random values selected you would want something like this
x = random.randrange(a, b)
y = random.randrange(b, c)
print(x)
print(y)
Upvotes: 4