Ask coding questions

← Back to all posts
its me again (i need to get good at python)
Imthebestthe (108)

how would I be able to define the different game modes and then when it would run the specific game mode. i realise i could just create two different files with the game modes and import them i just want to do it all in one file. thx


Well, you can just use functions. Then call the certain functions depending on the game mode selected.

Imthebestthe (108)

@JacksonCowie im kind bad at python so could you please help me with a demo. thx very much!


@Imthebestthe You should already know how to do a function. Oh wait, you didn't write this.

So a function in python works like this

def funcname() #"def" is the keyword that defines a function, "funcname" is the name of the function
    print("Hello world") #You can add pretty much anything here

funcname() # Now you need to call the function

That will output Hello World

I recommend you start learning python from easier projects first. Don't jump straight into Classes if you don't understand functions/procedures.

Imthebestthe (108)

@JacksonCowie thank you
will do!
by the way i did write this. i just havent done python in like 10 months


@Imthebestthe Anytime 🙂