0

sorry if I sound like a complete idiot when asking this, I'm very new to Python. When I create a function like this :

def load_content(name, colorkey=None, datatype):

It tells me there is a syntax error. From what I can tell, this is the right way to write a function. Like I said, I'm very new. Does anyone know what's wrong here?

3 Answers 3

3

You can't have default arguments between non-default arguments

def load_content(name, colorkey=None, datatype=None):

or

def load_content(name, datatype, colorkey=None):
Sign up to request clarification or add additional context in comments.

1 Comment

Wow! You were incredibly fast! Thanks for helping.
2

Default arguments must be at the end of the argument list, but before *args and **kwargs.

Comments

0

Default parameter MUST be the last variable. So change to:

def load_content(name, datatype, colorkey=None):
...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.