Python Forum
Another Error message. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Another Error message. (/thread-39553.html)



Another Error message. - the_jl_zone - Mar-06-2023

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



RE: Another Error message. - Axel_Erfurt - Mar-06-2023

change

txt=Text(str(number)

to

txt=Text(str(number))


RE: Another Error message. - the_jl_zone - Mar-06-2023

(Mar-06-2023, 10:06 PM)Axel_Erfurt Wrote: change

txt=Text(str(number)

to

txt=Text(str(number))

thx