Python Forum

Full Version: Another Error message.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This one is from an assignment using graphics.

POOL_BALL_RADIUS = 40
FONT_TYPE = "30pt Arial"


# Write your function here that draws a pool ball. (Make sure to use the correct name)
def draw_pool_ball(color,number,x,y):
    ball=Circle(POOL_BALL_RADIUS)
    ball.set_color(color)
    ball.set_position(x,y)
    add(ball)
    txt=Text(str(number)
    txt.set_position(x,y)
    txt.set_color(Color.white)
    txt.set_font(FONT_TYPE)
    add(num)


#function calls
draw_pool_ball(Color.orange, 5, 100, 100)
draw_pool_ball(Color.red, 3, 150, 350)
draw_pool_ball(Color.blue, 2, 250, 140)
draw_pool_ball(Color.green, 6, 50, 200)
Error:
Traceback (most recent call last): File __main__, line 13 txt.set_position(x,y) ^ SyntaxError: invalid syntax
change

txt=Text(str(number)

to

txt=Text(str(number))
(Mar-06-2023, 10:06 PM)Axel_Erfurt Wrote: [ -> ]change

txt=Text(str(number)

to

txt=Text(str(number))

thx