Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Go Interactive

Whether you’re learning about basic Python data structures (strings, lists, dictionaries, and so on) for the first time, or you are debugging an application, the interactive Python shell will be one of your best learning tools.

To use the interactive Python shell (also sometimes called a “Python REPL”), first make sure that Python is installed on your computer. To activate the interactive Python shell, simply open your terminal and run python or python3, depending on your installation. You can find more specific directions in First Steps With Python.

00:01 Go Interactive. The Python shell, or REPL, is a great way to instantly examine and create code. If you haven’t used it before, you’re going to see a quick introduction to it now. So, here you are in the command prompt or terminal, and to launch Python you either type python or python3 depending on how your system’s configured.

00:28 And here you are in the Python shell. You can create variables in the normal way,

00:40 but one thing you may not be aware of is you don’t need a print statement to see the result of what you do in the REPL. Here, if I type a + b and hit Enter, it gives us the result straight away.

00:56 One useful part of this is you can see the difference between a str (string) and an int straight away. So if I just hit a, here at the moment, we see 7.

01:05 But if I make a into the string '7' and type a again, we can see straight away that it’s a string, meaning we’re less likely to get confused as to whether we’re dealing with a number or a string.

01:21 As you’ve seen, it’s quick and easy to create code in the Python shell, but you can also use it to discover and explore the methods that are available to you. Now you can see this in action.

01:33 An important part of learning Python is understanding the methods which are available to you on objects that you’ve created. So for instance, in the case of strings, as we’ll see here, there are a number of methods which allow you to manipulate the string quickly and easily without you having to create that method yourself. Now you’re going to see that in action. Firstly, create a string.

02:00 Then next, to find out what methods are available, use the dir() command with the object inside the brackets. There, you can see a list of the methods which are available for that string.

02:15 Don’t be concerned about the ones which have double underscores (__) at the beginning. These are often called dunder methods, and while they’ll be important to you later on in your career, for the moment, don’t you concern yourself too much with them. However, there are quite a few useful methods, as you can see towards the end of the list.

02:35 One we’re going to take a look at right now is .upper(). This capitalizes the string, so just applying a.upper() gives us a capitalized version of the string.

02:51 Another one is .split(). .split() splits the string on a character that you choose. If you don’t give it one, it will split that string on a space (' '). So here, we will see it will return a list…

03:09 of 'hello' and 'there'. These built-in methods can be really useful, and it’s important to know what’s there so you don’t waste time duplicating something which already exists within Python itself. Remember, you don’t have to create an instance of the object to see what it can do.

03:27 So, here we can do dir() and then int, and we can see that mostly it’s those dunder methods, but there are a few available to us. And let’s have a look at float.

03:47 And see, similarly there, mostly they’re dunder methods, but there are a few available which you can make use of straight away. Another important part of the shell is that you can obtain help using the help() command. Now let’s see that in action.

04:04 Having access to help() about Python commands and functions is really useful, and it’s accessed really easily, just with the word help().

04:15 We put the object in question we want—in this case, int—and then hit Enter, and we’re taken into the help viewer. So we can see here that int is an object, and if we scroll down using the cursor keys, we can see that there are methods defined and you can see all those dunder methods, which we saw earlier on. If you want to move down faster, you can use the Spacebar to move down a screen at a time,

04:42 and B moves you backwards a screen at a time. When you’ve found the information you want, press Q to quit back to the Python shell.

Avatar image for stennow

stennow on April 2, 2020

in the:

help(int)

example how did you go back (or up if you like). Hitting “space” does skip a hole page at the time, but hitting “d” key did not go back for me. I have tried small d and capital d shift d and control-d and even tried it all with “b” also in case i heard wrong. but it does not work for me?

python 3.8 shell through CMD windows 10.

Regards René

Avatar image for vkvn

vkvn on May 1, 2021

Hello Rene,

The keybindings seem similar to VIM, so I am not sure if it works on Win10.

Cheers

Avatar image for Ms. S L

Ms. S L on June 14, 2025

Hi I hit q as recommended but it didn’t close, am I doing something wrong? Thanks

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on June 15, 2025

@Ms. S L You probably didn’t do anything wrong. The Q key is the correct shortcut to quit the pager app (like less) in most Unix-like terminal environments. If you can share a bit more detail about your setup, like how you ran the command and what you see after pressing the key, I’d be happy to help troubleshoot further!

Avatar image for Ms. S L

Ms. S L on June 16, 2025

Bartosz Zaczyński, thanks for responding. As far as setup I was IDLE and I was following the instructions regarding how to close the help menu. In the video it states to click on Q to minimize/close the help list

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on June 16, 2025

@Ms. S L Got it. Thanks for clarifying that you’re working in IDLE, not a plain terminal window.

In IDLE, the help() text isn’t shown in a pager like less, so the Q shortcut has nothing to quit. Instead, IDLE simply prints the help output straight into its shell (or pops up a separate read-only window.) Here’s how you can close it:

  • If it appeared in the shell, there’s nothing to close. Just press Enter once or twice to return to the >>> prompt, or use Ctrl + L to clear the screen if you want a clean slate.

  • If it popped up in its own window, that’s a normal system window. You can click the × (close) button, or use the OS shortcut.

Let me know if the above doesn’t match what you’re seeing.

Become a Member to join the conversation.