Reputation: 53
So when I call
plot_bounces( ball, numbounces, boxWH_tuple, circle=None )
where ball is an object, numbounces is an int, boxWH_tuple and circle are tuples, and put a print(type(circle))
statement in this function, it is a tuple. However, when I call update_ball(ball, boxWH_tuple, circle=None)
an put a print(type(circle))
statement in this function, it is a nonetype. I don't understand why nor how to make it a tuple for both functions. This is just part of my code which seems to be problematic.
This is what I used to call plot_bounces
plot_bounces(Ball(-1,0,0.1), 1, (3,2), ( (0,0) ,0.4) )
There's another script with class Ball which deals with the Ball object.
My main concern is why print(type(circle))
gives me class 'tuple' for the first print and class 'NoneType' for the second print.
def plot_bounces(ball, numbounces, boxWH_tuple, circle=None):
print(type (circle))
#make space to store coordinates
xcoords = []
ycoords = []
#store the starting point
xcoords.append(ball.x)
ycoords.append(ball.y)
while numbounces>0 :
#calls on update_ball and change the old values with new ones
update_ball(ball, boxWH_tuple, circle=None)
#
ball=update_ball(ball, boxWH_tuple, circle=None)
xpoint = ball.x
ypoint = ball.y
ycoords.append(ypoint)
xcoords.append(xpoint)
numbounces+= -1
def update_ball(ball, boxWH_tuple, circle=None):
print (type(circle))
Should't it be a tuple for both cases?
Upvotes: 0
Views: 67
Reputation: 1149
When calling update_ball()
from plot_bounces()
, please remove =None
after circle,
because when you do circle=None
in a call (call, not function definition), then you are passing that argument as a None and therefore the confusion.
The call should be update_ball(ball, boxWH_tuple, circle)
Upvotes: 1