I need help with my code, I don't know what I did wrong

It said I needed a comma, but I don’t know where

Here is the code

def when_started1():
    global myVariable
    pass
   
when_started1(

>  motor1.set_velocity(200, PERCENT)

motor1.spin_for(FOWARD) 
wait(5, SECONDS)
motor1.stop()
)

The line of code with “>” before it is where it says I need a comma, Advice?

Write it in blocks/etc. Then view the converted code. Should help. Also… 200% velocity? Does not sound right.

2 Likes

I am not very experienced with python, but I think that since you are putting the code in the input of the function “when_started1” it thinks that it is a parameter, which you would separate with commas, but since you didn’t define the function with any parameters I don’t think you meant to put the other code as an input to the function.

2 Likes

As already mentioned placement of your code is incorrect. I am assuming you are trying to move the motor1 for 5 seconds at 100% velocity.

Here is how you would do it:

def when_started1():
    global myVariable

    # put your code below
    motor1.set_velocity(100, PERCENT)
    motor1.spin_for(FOWARD) 
    wait(5, SECONDS)
    motor1.stop()

   
when_started1()

You can use blocks and view generated code in the codeviewer to get a better reference.

3 Likes

Thank you for your help, I am new to python.

1 Like