Oboe
No history yet

I want to learn python

Let's take a look at the learning path designed to build your Python skills from the ground up:

Your path
Variables and Basic Data Types
Control Flow and Decision Making
Working with Functions and Code
Lists and Collections Basics
We can adjust this path at any time to focus on your specific interests or speed. To make sure everything is tailored perfectly for you, what brings you to learning Python today, and do you have any prior programming experience?

I just want to learn Python for fun and to make simple games.

Making games is one of the most rewarding ways to learn programming. To start our journey, let's explore what Python is and why it has become the absolute favorite tool for game creators and beginners alike. Created by in 1991, Python is a general-purpose language that prioritizes readability, meaning its code looks incredibly similar to plain English. Because you do not have to worry about complex, cluttered syntax, you can focus entirely on designing your game's mechanics, storytelling, and logic. For example, while other languages force you to write several lines of setup just to display text, Python lets you do it in a single, clear line.
Because we want to get you building games immediately, we will use a to write our code. This means you do not have to download or configure any software on your computer; you can run Python code instantly in a web window. Before we write our first interactive game choice, let's start with the classic starting line for every developer: the print statement. It tells the computer to display a message on the screen, which is how your text-based games will talk to your players.

Which repl should i use

There are several wonderful, free options that let you run Python directly in your browser without any setup. A few of the most popular choices include , which is fantastic for building and saving multi-file game projects, and , which is a lightweight editor that lets you write and run code instantly. You can also use the official interactive shell directly on the website.
To make things incredibly easy as we start, I recommend opening online-python.com or any of those links in a new tab. Once you have a window open, you will see a main text area where you write your instructions, and a console screen at the bottom where your game will actually run. Let's try writing the line of code that will introduce our very first adventure game to the player.
print("Welcome to the Haunted Castle!")
Type that exact line into your editor window and click the green "Run" button. The print() function takes the message inside the double quotes and displays it on the black console screen below. Once you run this, you have officially written and executed your very first Python game statement.

Continue: I ran it! How do we save the player's name in a variable?

Now that you have run your first line of code, we are ready to introduce . In game programming, a variable is like a labeled storage box in the computer's memory. Instead of forcing the computer to forget information the instant it finishes running a line of code, you can use a variable to store things like player names, high scores, or health points to use later in your adventure.
Creating a variable in Python is incredibly straightforward because Python is a . This means you do not have to write complicated setup code to declare what kind of data you are storing; you simply type the name of your variable, followed by an equals sign (=), and the value you want to assign to it. Let's create a variable called player_name and set it to a starting name like "Alex".
player_name = "Alex"
print("Hello, " + player_name + "!")
In this code, we first create the variable player_name and assign it the text value "Alex". In programming, text characters wrapped in quotes are known as strings. In the second line, we use the + symbol to join, or , our text pieces together. The print() function then displays the combined message. Try typing those two lines into your REPL window, hit "Run", and see how Python greets the player by name.

Continue: How do we let players type in their own custom names?

To make our game interactive, we need a way to let players type in their own custom names. In Python, we do this using the . This function acts like a listening ear: it pauses your game and waits for the player to type something into the console and press Enter.
To capture and remember what the player typed, we assign the result of the input() function to a variable. We can even pass a message inside the parentheses of input() to show a prompt, so players know exactly what they are supposed to type. This is how we keep our code incredibly clean while building a custom greeting.
player_name = input("Enter your character's name: ")
print("Welcome to your adventure, " + player_name + "!")
Try running this new block in your REPL tab. When you click run, you will see the prompt asking for your name. Click inside the console area at the bottom, type any custom name you want, and hit Enter to see Python dynamically greet you.

Explain this command of Print, hello, plus player, name and plus !

Let's break down this command line-by-line to see exactly how Python constructs our game greeting. The entire line is centered around the , which acts as the megaphone of our game, taking whatever text is inside its parentheses and displaying it to the player's screen.
Inside the parentheses, we are using a process called to glue three distinct pieces of data together using the + operator. In programming, the + sign doesn't just add numbers; when placed between pieces of text, it acts as a digital glue, merging them end-to-end into one single message.
Code PieceTypeWhat It Represents / Does
"Hello, "String (Static Text)The opening greeting. Notice the space inside the quotes after the comma!
+OperatorThe glue that joins the preceding piece of text to the next piece.
player_nameVariableThe storage box holding whatever custom name the player typed in.
+OperatorThe glue that joins the player's name to our final punctuation.
"!"String (Static Text)The exclamation point wrapped in quotes to wrap up the sentence enthusiastically.
One critical detail is the space inside the double quotes in "Hello, ". Python is very literal and will not automatically insert spaces for you. If we wrote "Hello," without that trailing space, the final joined output would look like Hello,Alex! instead of Hello, Alex!. Including the space inside our ensures the computer formats the sentence correctly for human eyes.

If player_name currently stores "Sam", what will print("Good luck " + player_name + "!") display on the screen?

Good luckSam!

You hit the nail on the head. Because we did not include a space inside our first text string, Python glued the characters directly together without any padding, resulting in Good luckSam! rather than a formatted sentence. Spotting how literal the computer is with spaces is a major milestone in mastering game dialog.
Computer Programming
LV 1
Python
LV 1
Skills
Now that we have variables and basic down, we have completed our first big steps. Let's look at our path ahead to see how we can use these tools to build real interactivity.
Your path
Getting User Input and Logic
Loops and Game Repetition
Functions and Modular Game Code
Lists, Randomness, and Simple Games
Now we are ready to move into our next focus: Getting User Input and Logic. To make our games truly feel like adventures, we need to let the player make choices and have the game react differently depending on what they choose. This is where come in.
To do this, we use the if keyword. This tells Python to run a block of code only if a specific condition is met. For example, if a player chooses to go left, we print one message; if they go right, we print another. Let's see how this looks in code:
choice = input("Do you want to go left or right? ")
if choice == "left":
    print("You walk into a dark room and find a treasure chest!")
In Python, we use the double equals sign == to check if two values are equal. Notice the on the second line. In Python, the four spaces at the start of the print line tell the computer that this statement belongs inside the if block, meaning it will only run if the player typed "left".

What happens if the player types right instead?

If the player types "right" instead of "left", the computer completely ignores the indented block of code underneath the if statement. Because the evaluating choice == "left" turns out to be False, Python simply skips over that print line and continues running any code that comes afterward. In our current script, since nothing else is written, the game would quietly end, leaving your player staring at a blank console screen.

To prevent our game from ending abruptly and to make sure we react to other decisions, we can use an else statement. Think of else as the ultimate safety net: if the if condition turns out to be False, Python will jump straight to the else block and run whatever is inside it instead. This lets us handle alternative paths without writing a second check.

choice = input("Do you want to go left or right? ")
if choice == "left":
    print("You walk into a dark room and find a treasure chest!")
else:
    print("You step to the right and fall into a bottomless pit!")
Notice how the else keyword has a colon after it and is lined up perfectly with the if statement, while the second print line is also indented by four spaces. If you run this code in your editor and type "right", the computer will skip the first chest and print the tragic news of the bottomless pit.