Where are the Unity Editor Logs?

If you run the Unity Editor and erased the Console Log, you might want to access the previous Editor Log.

They are in the following folders:

macOS ~/Library/Logs/Unity/Editor.log 
Windows C:\Users\username\AppData\Local\Unity\Editor\Editor.log
Windows with Backslashes C:/Users/username/AppData/Local/Unity/Editor/Editor.log

Check the above folders for your operating system and check out the log!

Where are the Unity Standalone .exe Game Logs?

If you have downloaded a Unity Standalone game folder, and the game crashes or has problems, you might need to check the Standalone .exe logs.

They are in the following folders:

macOS ~/Library/Logs/Company Name/Product Name/Player.log
Windows C:\Users\username\AppData\LocalLow\CompanyName\ProductName\Player.log
Windows with Backslashes C:/Users/username/AppData/LocalLow/CompanyName/ProductName/Player.log
Linux ~/.config/unity3d/CompanyName/ProductName/Player.log

Check the above folders for your operating system and check out the log!

How to Setup HTTPS for Free With Terminal

In this article, I’ll show you how to setup HTTPS for your website as long as you have shell/terminal access.

  • We host slothparadise on Amazon Web Services EC2, so we do have shell access to the website.

You should visit https://certbot.eff.org to get customized instructions for your operating system and web server. Let’s Encrypt has more information.


1.  Find out what type of web server and operating system you are using.

Open a terminal and ssh into your website.

ssh [email protected]

Once you are connected, you will see what version of your operating system.

Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-24-generic x86_64)

Next, you should find out what type of web server you are running. I know beforehand that I am running an apache server, so I should check the status of apache.

~$ sudo service apache2 status
* apache2 is running

As a result, at the certbot.eff.org website, I’ll select Apache for Software and Ubuntu 14.04 (trusty) for System.


2. Follow the instructions that pop up.

Next up is simply following the instructions for Certbot.

$ sudo add-apt-repository ppa:certbot/certbot

$ sudo apt-get update

$ sudo apt-get install python-certbot-apache

Type Y to continue.

certbot is ready to be used, but we still need to check if the 443 port is ready.


3. Check if port 443 is open.

$ sudo apt-get install nmap

nmap is a useful tool on Ubuntu to see what ports you have open.

$ nmap localhost
Starting Nmap 6.40 ( http://nmap.org ) at 2017-04-30 03:52 UTC
Nmap scan report for localhost (
Host is up (0.00028s latency).
Not shown: 997 closed ports
22/tcp open ssh
80/tcp open http
3306/tcp open mysql

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

nmap shows that I do not have 443/tcp open, so that means that I need to add open port 443.


4. Open port 443 if it’s not open.

Since I host the website on Amazon Web Services EC2, I have to visit https://aws.amazon.com and log into my account.

Once I’m on my dashboard, I need to visit EC2.

Next, I click on Running Instances.

I click on the running instance that I want to edit, and the checkbox becomes blue.

Afterwards, I look at the bottom of the page where there is additional information in the Description tab and click on the name of the Security Group.

If you click on Actions, you can Edit inbound rules of the Security Group.

For Edit inbound rules, we want to Add Rule HTTPS.



Hit Save.


5. Use cerbot to add HTTPS to your website.

$ sudo certbot --apache

You will get a message to choose whether to allow both HTTP and HTTPS access or only HTTPS. I like option 2, so I type 2 and hit Enter.

If everything worked properly, you should get a Congratulations message.

Now, you can visit your website with HTTPS. Huzzah!


Automatic HTTPS certificate renewal

You will also get a message that your certificate will only last 3 months, but luckily, it should renew by itself.

Your cert will expire on 2017-07-29. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew"

However, the Certbot packages on your system come with a cron job that will renew your certificates automatically before they expire. Since Let’s Encrypt certificates last for 90 days, it’s highly advisable to take advantage of this feature.

You can check the certbot cron entries (automated scheduler):

vim /etc/cron.d/certbot

0 */12 * * * means every 12 hours.

You can test automatic renewal for your certificates to make sure that this automatic renewal will work in the future by running the following command. I like to test that certbot will renew correctly.

certbot renew --dry-run


Always redirect to HTTPS

What controls the redirection to HTTPS on apache is the .htaccess file.

You can follow Namecheap’s official documentation on how to force a HTTPS redirection.

.htaccess is typically found in the /var/www/html folder

$ sudo vim /var/www/html/.htaccess

In my .htaccess file, I made sure to have a section with the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

php_flag display_errors 1

This snippet’s most important part is the RewriteRule that states the redirection to https version of the website.

Save the file and restart apache.

sudo service apache2 restart
 * Restarting web server apache2 [ OK ]

Your website should now always redirect to HTTPS.

How to Setup Bash on Windows 10 for Developers – Ultimate Setup

Bash for Windows 10 has been out for almost a year now. It has been incredible for a developer like myself to be able to use Bash natively on a Windows machine!

In this article, I’ll show you how I install my main Bash setup for Windows 10.



  1. Your Windows 10 PC must be running a 64-bit version of Windows 10 Anniversary Update build 14393 or later.
    To find your PC's CPU architecture and Windows version/build number, open Settings>System>About. Look for the System type and OS Build fields.

    In this screenshot, I have a 64-bit operating system, x64-based processor and OS Build, 15063.138, so I fit the requirements.



  1. Install Bash on Windows 10
  2. Install ConEmu for tabs
  3. Must have Bash customizations
  4. Install VcXsrv Windows X Server for opening GUI applications


1. Install Bash on Windows 10

In order to run Bash on Windows, you will need to manually:

  1. Turn on Developer Mode
  2. Enable the “Windows Subsystem for Linux (beta)” feature

Open Settings -> Update and Security -> For developers
Select the Developer Mode radio button.

Developer mode is selected.

From Start, search for “Turn Windows features on or off” (type ‘turn’)
Select Windows Subsystem for Linux (Beta)

Windows Subsystem for Linux (Beta) is checked.

Hit OK. Installation will proceed, and afterwards, you will have to restart your computer.

After you restart your computer, you will be able to finish installing Bash on Windows 10.

Search for Microsoft Store.

From the Microsoft Store, find Ubuntu and download and install it.

From Start, search for “bash” (type ‘bash’) or it might already be open.

When you open bash, you will see a command prompt window.

Type "y" to continue.

The real “Bash on Ubuntu on Windows” shortcut will be installed. Bash on Ubuntu on Windows might already be installed through the Microsoft Store.

Now, you can open “Bash on Ubuntu on Windows” whenever you search for “bash”

Try opening Bash.  The first time you install Bash on Windows, you will be prompted to create a UNIX username and password.

After typing in a UNIX user name and UNIX password, you can use Bash the same way that you would use a terminal on Mac and Linux.

The biggest problem though is there are no tabs! Let’s fix the tab issue.


2. Install ConEmu for tabs

ConEmu is an amazing program that gives you terminal tabs, allows you to copy and paste the normal way with CTRL-C and CTRL-V, and run any combinations of shells including Command Prompt, Bash, Powershell, and more.


Hi the Download button, which will take you to a redirected list of versions of ConEmu. I like to use the Preview version.

Run the executable. Select the x64 bit version of installation.

Hit Next on the next few prompts, which are the intro window, license and agreement, and settings. I leave everything by default.

Now, you are ready to install. Hit Install.

Hit Finish on the next prompt.

From Start, search for “ConEmu” (type ‘ConEmu’)

When ConEmu first starts, you will be brought to the Startup Settings. You have to select the default console that you want to open.

Find and select {Bash::bash} in the Specified named task section.

Now, whenever you open ConEmu, it will open to Bash by default! ConEmu is easy to read and smooth.

I like to pin ConEmu to the taskbar to be able to open bash quickly. Right click ConEmu’s icon and click Pin to taskbar.

To add a new tab on ConEmu, type WIN+W.

To switch to the right tab, type CTRL+Tab.

To switch to the left tab, type CTRL+Shift+Tab.

All ConEmu’s shortcuts are listed: http://conemu.github.io/en/KeyboardShortcuts.html


3. Must have Bash customizations

Bash on Windows 10 is great, but it could use a few customizations to make using it with Windows 10 files and programs easier!

First, we will adjust our ~/.bashrc.

nano ~/.bashrc

Use any text editor. On nano, type ALT+/ to go to the end of the file.

These configurations allow easy access to some of my favorite Windows related directories and programs.

I want to be able to change directory to the Windows C: drive easily and access my desktop, so I use aliases.

alias converts the given word into shortcuts.

I also want to be able to use Sublime, which is my go-to GUI text editor, so that I can type subl . and open the current working directory with Sublime.

I am using Sublime 3https://www.sublimetext.com/3

I want to be able to open any folder with File Explorer with open, so that I can open the current working directory with open .

I have a shortcut called linux to open the Ubuntu’s root folder with File Explorer.

Lastly, I have an alias called reload for reloading the ~/.bashrc to apply any new configurations.

Replace huyle with the username of your computer.

# Custom shortcuts
alias windows="cd /mnt/c"
alias desktop="cd /mnt/c/Users/huyle/Desktop"
alias subl="/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe"
alias open="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe /c start -WorkingDirectory C:'\\'Users'\\'huyle'\\'AppData'\\'Local'\\'lxss"
alias linux="open C:/Users/huyle/AppData/Local/lxss"
alias reload="source ~/.bashrc"

These other shortcuts I use to access my favorite directories. I recommend you to add your favorite Windows or Ubuntu directories where you put your development code or work.

# Optional shortcuts
alias repos="cd /mnt/c/Users/huyle/Desktop/Repos"
alias work="cd /mnt/c/Users/huyle/Desktop/Work"
alias youtube="cd /mnt/c/Users/huyle/Desktop/YouTube"

You can save your file with nano by using CTRL+O and then pressing Enter.

Now, we can apply these changes.

source ~/.bashrc

Use the windows alias to easily switch to your Windows files! You can try some of these other aliases!

open .

The open alias does not work with Ubuntu’s directories because of directory translation errors, but by default, at least, I set the alias to open the Ubuntu root directory.

Every now and then, I prefer using Sublime, so it’s very convenient to be able to type subl . in order to open current working directories with Sublime.

Here are some extra utilities that I like to install on Bash. These utilities are optional.

I like to use tmux, which is a terminal multiplexer. It lets you switch easily between several programs in one terminal.

I like tabs, but every now and then, I like everything in one terminal for a bird’s eye view.

I also like to use zip and unzip often to create zip files and extract them.

sudo apt-get install -y tmux zip unzip

Nice! Bash on Windows 10 with tabs and tmux feels so good. Your development is now super-charged!


4. Install VcXsrv Windows X Server for opening GUI applications

If you have ever wanted to open GUI applications through SSH connections, this step is for you.

By default, Windows 10 does not come with an X11 server by default. I’ve been using VcXsrv Windows X Server, but Xming also works.

You can download VcXsrv Windows X Server here:


Hit the Download green button.

I leave the settings by default.

You can open VcXsrv by searching for “vcx” on Windows 10 search.

I Allow access for VcXsrv Public networks.

Now that we have our X11 server open, we should adjust our ~/.bashrc a little bit to make sure that the DISPLAY value will be correct.

vim ~/.bashrc
# X11 server display value
export DISPLAY=localhost:0.0

Let’s test if our X11 server works! I like to install x11-apps for testing.

x11-apps contains xclock, which is great for testing GUI applications and X11.

sudo apt-get install -y x11-apps

Now, let’s run xclock.


Last but not least, let’s make sure that X11 will work on top of SSH connections.

mkdir ~/.ssh
vim ~/.ssh/config
Host *
    ForwardAgent yes
    ForwardX11 yes

Now, save the ssh config file and change its permissions correctly.

chmod 600 ~/.ssh/config

Afterwards, you should be able to use -X with ssh in order to enable the forwarding of X11 connections to VcXsrv.

ssh -X [email protected]_address

Great job! Good luck with your development. I’ve been finding this setup very comfortable as a developer!

Introduction to Python – Chapter 9 – Dictionaries and Sets

In this video, we’ll talk about dictionaries and sets.

For strings, lists, and tuples, we have been using integers as the indices and position numbers in order to get their values.

Dictionaries are similar to lists except that instead of using integers as the indices, dictionaries can use any string or number or immutable type as the index.

Let’s create a dictionary to demonstrate how it works.

We will create a dictionary called states.

Instead of using number indices, we will use the state’s abbreviation as the index, and the state’s full name as the value.

An index in a dictionary is called a key.

The values in a dictionary are still called values.

As a result, we call the individual elements of a dictionary, key-value pairs.

First way to create a dictionary is by creating an empty dictionary.

After creating the empty dictionary, we can assign new keys to new values.

Here I created an empty dictionary, using a pair of curly braces.

Every key points to a specific value.

We can print this dictionary.

When we run the program, we see how a dictionary is formatted.

A dictionary is enclosed by a couple of curly braces.

Each element of a dictionary has the key followed by a colon followed by the key’s value.

Each element is separated by a comma like a list.

Every key has a value.

Another way to create a dictionary is to assign a variable to a dictionary with a few key-value pairs.

For example, let’s delete this snippet of code.

Now, we’ll write the same dictionary that we deleted except we’ll pre-populate the dictionary instead of assigning separate keys to values.

When we run the program, we get the same dictionary that we printed out with our first method of creating a dictionary.

All you have to remember is a pair of curly braces, and then, the keys are followed by a colon and a value.

Before Python 3.6, key-value pairs of dictionaries were not stored in order.

I’m using Python 3.6, but you might be using a different version of Python, which means that the key-value pairs might not be in order.

From Python 3.6 and onward, a dictionary maintains insertion order by default.

To access a value in a dictionary, you use a pair of brackets like you would with a list.

If I wanted to get the full state name for California, I would write:

When I run the program, I get “California” because “California” is the value for the “CA” key.

You can delete key-value pairs like how you would delete values of a list.

Let’s try to delete the “MA”: “Massachusetts” element.

When we run the program, the “MA”: “Massachusetts” element is deleted.

We can also get the length of a dictionary too.

When we run the program, we get the length of the states, which is now 2.

Just like lists, dictionaries are passed by reference.

A variable that is assigned a dictionary variable changes the actual dictionary.

Let’s first delete the del statement.

If I set b = states, changes to b will affect states.

When I run the program, I can see that the assignment of “CA” for b changed the states dictionary.

Dictionaries are passed and assigned by reference. Not by value.

We can use for loops with dictionaries.

If you use the for loop like you would with a list, i will be the keys of the dictionary.

When we run the program, we get the keys from states.

You can get the values separately. If you want just the values, you can use the .values() function on a dictionary.

When we run this program, we’ll get the values of states.

Most of the time though, we want both the keys and the values.

To get both the keys and values of a dictionary, we use the .items() function on a dictionary.

When we run the program, we get both the key and value from states.

You can see each state abbreviation followed by the full state name.

Most of the time, I need to grab both the key and value, so I normally format my dictionary for loops using the .items() function.

We can check if a dictionary has a particular key. Like in a list, we can check for membership in a dictionary.

For example, we can check if states has the “MA” key.

When we run the program, we see the print statement, “MA is in states dictionary.”, because “MA” is a key of the states dictionary.

You might be thinking what makes a dictionary so different from lists?

Is the only difference between a dictionary and a list the fact that a dictionary can have different types like strings for the indices?

Let’s review the main differences between a dictionary and a list.

First, we’ve talked how a dictionary can have different types for its keys.

On the other hand, a list is ordered with numeric indices, starting from 0.

Second, you may have noticed already that dictionary keys are unique.

We can reassign and delete existing key-value pairs like what we did for states, but a dictionary always forbids duplicate keys.

Dictionaries are good data structures for holding unique data.

In our example, we created a dictionary to hold the abbreviations of states because we know that every state has a unique abbreviation.

In contrast, a list can hold duplicate values.

Technically, a dictionary can also have duplicate values, but since a dictionary can only have unique keys, we use dictionaries whenever we have data with unique identifiers.

Third, checking for membership in a dictionary is much faster than checking for membership in a list.

Checking for membership in a dictionary takes about a constant, fast amount of time whereas checking for membership in a list takes time proportional to the list’s length.

I emphasize performance speed in these videos.

When talking about Computer Science in Chapter 1, I said that Computer Science is about figuring out:

“What can be computed? How can we compute it? and especially How fast can we compute it?”

Paying attention to performance speeds of every data structure you use is important to being an efficient problem solver in Computer Science.

Let’s talk about sets. A set is like a dictionary except it only contains keys.

A set is just a unique collection of values.

Let’s make a set of fruits.

You will notice that a set looks very much like a list except it uses curly braces like a dictionary.

You can add new values to a set with the set.add() function.

When we run the program, you will notice that adding new values in a set does not put them in order.

Sets are not about order. If you want to keep an ordered sequence, then use a list.

You can remove values from a set, but you can only remove that value from a set if it is already in the set.

If the value you want to remove is not in the set, then you will get an error.

Let’s check for membership in the set, and if “pears” is in the set, then we’ll use the .remove() function.

When we run the program, since “pears” is in the fruits set, we remove “pears”.

We can see that fruits no longer has “pears.””

You can use a for loop with a set.

When we run the program, we will get every fruit string in the fruits set.

Let’s review the aspects of sets.

Sets cannot have duplicate values, so sets are good data structures for holding unique data.

Accessing elements of a set is a pain since sets don’t support access by index.

Checking for membership in a set is as fast as dictionaries.

The big question is when should you use lists, dictionaries, and sets?

Ask yourself:

Do you just need an ordered sequence of items? Use a list.

Do you need to associate values with keys, so you can check for membership efficiently and find the values (by key) later on? Use a dictionary.

Do you just need to know whether or not you already have a particular value but without ordering (and you don’t need to store duplicates)? Use a set.

Most of the time, you’ll be focusing on lists for ordered sequence of items and dictionaries for unique key-value pairs of data because accessing values in a set is just not very flexible.

When you know that you have to search your data for membership or you don’t want any duplicate data, think about using dictionaries or sets.


Video Demonstration

Introduction to Python – Chapter 8 – Lists, Matrices, and Tuples

In the last video, we talked about lists.

There are a couple of more things that we need to talk about lists including matrices.

Let’s say that we had two lists:

With lists, a and b are the same thing. If I change b, then a is also changed.

Let’s test changing b.

When we run the program, we can see that even though a was a list with 1, 2, 3, 4, and 5, and we didn’t change a, a’s value at index 0 is now 0.

We assigned b at index 0 to 0.

What we find out is that changing b also changes a.

With lists, b = a is an assignment by reference.

Assignment by reference is a fancy way of saying that there’s an assignment pointing b to a.

b = a is not a copy of a. b and a are the same variable.

The variable b points to where a was created, so changes to b affect a.

Instead of doing this example with lists, if I were to use integers or strings, assigning b to a would be an assignment by value.

Assignment by value means that there is a copy of the variable, which makes b independent to a.

Remember that assigning b to a with lists is an assignment by reference. b and a are the same variable.

This aspect of lists affects how we use lists in functions.

Let’s make a function to delete the end of a list.

This function will delete the last value of a list.

When you use a list as an argument in a function, the list is passed by reference.

Passed by reference means that whatever we do to the variable will change the original.

Even though the parameter has a different variable name, the list_parameter and list_argument are in fact the same variable.

list_parameter is not a copy of list_argument. There is only 1 variable. They are the same variable.

Any change that happens to list_parameter affects list_argument.

We can add a print(list_argument) to see if the deletion of the last value in the list_parameter affects list_argument.

When we run the program, we will see that list_argument has 1, 2, 3, and 4. 5, which was the last value was deleted.

If we were using integer or string parameters with functions, those arguments are passed by value.

Passed by value means that there is a copy of the variable. The variables will be independent.

Remember that using a list as an argument will be a pass by reference. The argument and parameter will be the same variable.

We didn’t talk too much about using a list in a list.

A list in a list is used to create a matrix.

A matrix is a fancy way of saying a table of data.

Just think about a Microsoft Excel spreadsheet.

If we think about a list, it’s just a row of comma separated values.

The difference between a matrix and a list is that a matrix has multiple rows and columns.

A 3 by 3 matrix would be a 3 by 3 table with data:

Each row is a separate list, meaning that each row is enclosed in brackets.

Then, the entire matrix is contained in a list.

We can write this matrix in a single line like:

The matrix is a list. Then, each row is a list element in the list.

How we access a value in a matrix is we use the index from the row, followed by the index of the column.

For example, if I wanted to get the first value in the matrix, which would be row, 0, and column, 0, I would write.

You can extract any matrix value this way. Just think of using the double brackets, get the row first, then the column second.

When we run the program, we get 1, because 1 is at row, 0, column, 0, of the matrix.

You can use for loops with matrices.

When we run the program, we’ll get all the values of the matrix.

In this for loop, the first for loop traverses the rows.

Then, the second for loop looks at the length of the current row in order to traverse the columns.

Inside the column for loop, we’re accessing the cell at the row column index.

The last thing that we’ll talk about lists is that strings can be converted into lists, and lists can be converted into strings.

To convert a string into a list, you can use the .split() function.

The .split function works well with comma separated values.

The csv files that you’d normally use with Microsoft Excel or a different spreadsheet program.

Let’s say that we had a string:

We can see that there are words in the string separated by commas.

This string would be much more useful to us as a list.

Inside the parentheses, you put the character or string that you want to separate the string by.

I want to separate the string by its commas. Every time, there is a comma, it creates a new value in the list.

When we run the program, we can see that fruit_list is a list where each value is the fruit string before a comma appeared.

We have apples, bananas, mangos, oranges, and strawberries each as a value in the list.

Next, we can change a list to a string.

Let’s say that we had a list that looked like a sentence, so it’d be more useful to us as a string.

We can use the .join() function to join each value of the list together to make a string.

Before the .join(), we put the string that we want to use to separate the values of the list.

I want to put a space between each value of the list to make a proper sentence.

Inside the parentheses, we put the list.

I can print out sentence, and I’ll get, “Are you learning Python?” as a string.

Let’s talk about tuples. Tuples are very similar to lists.

They contain an ordered set of values like a shopping list or a checklist just like a regular list.

The big difference between tuples and lists is that tuples are immutable, meaning that its values cannot be changed.

Lists are mutable, meaning that list values can be reassigned and changed.

You can create a tuple with the same setup as a list, but instead of square brackets, you use parentheses:

However, even though you use parentheses to create a tuple, you use square brackets to access elements of a tuple.

Let’s say that we wanted to get the first element of this tuple_example.

When we run the program, we get 1, which is the first value of the tuple_example variable.

Now, you might be thinking, why would we use tuples? You can’t change the values in tuples!

Tuples also lack many of the functions that we demonstrated that lists had in the last video.

The main benefit of a tuple is that tuples are faster for constructing a list of values.

If you need to create a list of values that you won’t need to access and manipulate later, using tuples might be for you.

For example, let’s say that we wanted to create a function that swaps two values.

In the function, we are creating a new tuple with x and y swapped with each other.

Tuples are good for quick construction and usage. Tuple construction is faster than list construction.

When we run the program, swapped_values variable will have a tuple with 2, 1.

Tuples, being immutable, are a tad more memory efficient, but it’s almost negligible.

Most of the time, I use lists because there are many situations where I need to manipulate the values of a list.

I would only use tuples whenever I have a simple function where I knew that I would not have to manipulate the values of the tuple beforehand.

If you want a function to return a few values that won’t be changed, feel free to use tuples.


Video Demonstration

Introduction to Python – Chapter 7 – Lists

In this video, we’ll talk about lists.

List is the term used for an ordered sequence of values where each value has an index.

Before we continue to talk about lists, there is also a term called arrays from other programming languages that you might have heard about.

Arrays are almost exactly like lists in Python. There’s an array module in Python for using arrays.

In Python, arrays can only hold data of the same type. Lists can hold multiple data types.

Python arrays are better than lists memory-wise. But in Python, lists are better performance-wise than arrays.

If you know about arrays from a different programming language, use lists in Python because lists in Python are faster than arrays.

Most of the time, speed is more important than memory when talking about these data structures.

Usually when people say “array” when talking about Python, they mean “list” because lists are fundamental to Python the same way arrays are fundamental to other programming languages.

When we talk about a list, just think of any list of values like a shopping list or a checklist.

Every value inside a list has an index.

An index is the numbered position of a value in a list.

The first value in a list starts at index, 0. The second value has index, 1, and so on.

The actual values in a list are called elements.

Lists are like strings in the way that they can be broken up into their individual parts.

The difference between a list and a string is that the values in a list can be of any type.

Let’s make a list to demonstrate. To make a list, you use a couple of brackets.

In those brackets, you include each value and separate each value by a comma.

In Python, the values of a list don’t have to have the same type.

We can mix values of different types in a list like:

When you put a list in a list, the list inside the list is called a nested list.

We can print out the lists.

When we run the program, the lists are printed with their values.

We can make a list without any elements. This type of list is called an empty list.

Let’s talk about how you can access a list.

You can access each element of a list with its index.

If I wanted the first element of example_list, which is 1, I would write:

When I run the program, I get the 1, because the first value of a list starts at index, 0.

You simply write a pair of brackets and put the index in between the brackets.

You can use the len() function on a list the same way that you could use the len() function with a string.

The last value in a list has the index, len(list_name) – 1.

We will get the value, 4, because it’s the last value in the list.

You can also use -1 to represent the last index in the list, but most people don’t prefer to use the negative numbers to represent the indices.

Like with strings, if we were to access an index of a list that does not exist, we’d get an IndexError.

There is no index that is the length of the list, example_list, so when we run the program, we get an IndexError.

Let’s talk about using iteration and loops with lists.

The while loops and for loops that we talked about in previous videos can be used with lists to visit and get the values of a list.

You might want to visit every value in a list.

If you’re visiting every value in the list, then you should use a for loop because there’s a counting process where you have a start position progressing toward an end position.

I’ll repeat the most popular for loop concepts that we talked about in the last video.

The most popular way of using a for loop with a list is visiting every value of the list.

This for loop is the simplest to make. It uses the for keyword followed by a variable that you name.

I used i in example_list, which means i will take the value of each value of the list at each step.

When you want to create this type of for loop, the general setup is always:

If you read the for loop in English, it becomes easier to understand.

for every variable in list, do something to the variable.

When I run the program, I get the contents of the list printed out line by line like how we printed out the characters of a string in the last video.

The second popular way of traversing a list with a for loop is using enumerate keyword.

Using enumerate keyword allows you to not only get the value of each position in the list, but also get the index.

For example, we can write:

We use the for keyword followed by two variables this time around. I named the variables index and value. Then, in enumerate the list.

enumerate allows you to retrieve both the index and value in that order, which is why I used the variables, index comma value.

When we run the program, we’ll get the index followed by the value printed out.

Let’s talking about checking if a value is in a list. Checking for membership.

Let’s say we wanted to check if “microwave” was in this list.

When we run the program, since “microwave” is inside appliances, we get “microwave in appliances”.

You can use operators on lists.

Let’s say that I wanted to combine two lists.

c becomes a new list with the contents of a and b.

The list will be [1, 2, 3, 4].

When I run the program, I get the new list with a and b’s list values.

The multiply operator can repeat the contents of a list.

For example, let’s say that I wanted to multiply a’s contents by 3 times.

When I run the program, I get [1, 2, 1, 2, 1, 2]

The values inside a, which were originally 1, 2 are tripled because I multiplied a by 3.

We call using operators on lists, list operations.

In the last video, we talked about string slicing, which was the ability to grab a subsection of a string without using a for loop.

Lists can also use slicing.

If I wanted to get a list with a, b, and c, I would use list slicing.

How list slicing works is you have a start position followed by a colon followed by the end position + 1.

The start position 0 in list slicing is inclusive. example_list at index 0, which is “a” is included in the new list.

Then, the list slicing visits every value in between start position until end position.

The end position 3 is non-inclusive, which means that example_list at index 2, which is “c” is included in the new list, but example_list at index 3 is not included. 0 is inclusive. 3 is non-inclusive.

When we run the program, I’ll get the half_list, which is a new list with “a”, “b”, and “c”.

In the last video, we talked about how strings were immutable, meaning that we could not change the characters of a string with different characters.

Lists are mutable in Python. We can change the elements of a list.

The first value of the list is changed to a “b”.

You can also do fancy things like use list slicing to assign new values.

For example, I could use list slicing to change the first three values of the list.

example_list[0:3] = [“x”, “y”, “z”]

Now, when I print example_list, the first three values will get the x, y, z because I used string slicing to get the first three values then I reassigned them with x, y, z.

I can run the program, and I’ll see that the program has the “x”, “y”, “z”, “d”, “e”, “f”.

Let’s say that we wanted to add new values to the list.

There’s a very useful append function that lists can use to add new values to the end of a list.

When I run the program, we can see that the last three values of the list are g, h, and i, which were added with the .append function.

Let’s say that we wanted to sort the values in a list.

example_list = [“b”, “a”, “e”, “c”, “f”, “d”]

You can use the list’s sort function.

Sorting a list can be very useful. All you need to do is add a .sort().

When we run the program, we can see that the values in the list have been sorted in alphabetical order.

Another very useful list function is reversing a list.

Let’s take that sorted_list and reverse it.

All you need to do is add a .reverse() to the list. When we run the program, we get the reversed list.

The last thing that we’ll talk about is list deletion, which means that I can delete values in a list.

Let’s say that I wanted to delete the last value in the list.

First, I’ll get rid of example_list.reverse().

When I print example_list, “f”, which used to be the last value of the sorted list has been deleted.

There are more functions that you can use with lists, but we’ve talked about the most useful ones so far.

Google is your friend, so if you ever can’t figure out how to get a specific value from a list, Python might already have a built-in function that does exactly what you’re looking for.


Video Demonstration

Introduction to Python – Chapter 6 – Strings and For Loops

In this video, we’ll talk more about strings and explain the for loop.

A string is a data type created when we use a pair of quotation marks.

is an example of a string.

Let’s say that I wanted to get the “m” character in “microwavesam”.

A character is the term used for a single symbol in Python.

In Python and programming languages, we also use the term, element.

An element is a term for any individual part of a string.

To get a character in a string, you grab its index.

An index is a fancy term for a member of a set of parts.

For example, to get “m”, I could write,

bracket 0 bracket is the index.

The index is just a fancy term for a position in the string.

In Python and programming languages, the position of the first character starts at 0.

The reason why position starts at 0 is because an index represents the offset from the first character.

At the first character, I am 0 positions away from the starting position.

The first character is m. At the starting position, I am 0 positions away from the first character.

If I print first_letter, I will get an “m”.

When I run the program, I get the first_letter, which was at index 0.

I can get the second letter by assigning:

When I run the program, I also get the second letter, i, which was at index 1.

Just remember when getting a single character from a string while using an index, the first character’s index starts at 0.

Next thing that we’ll talk about is length of a string.

Python strings have a len function that allows you to get the length of a string measured in the number of characters.

If I write,

I will get the number of characters that make up “microwavesam”, which is 12.

The len function is very useful for getting the last character of the string.

If I wanted the last “m” in “microwavesam”, then use len_username – 1.

The last character’s index is 11 since the first chracter’s start position was 0, which means that the last character’s index is len_username – 1.

If I try to get the character at an index out of range, then I’ll get an IndexError.

For example,

I can try to get the index of username at length of username.

When I run the program, I get the IndexError, because there is no character at that index.

The last character’s index is len_username – 1. Not len_username.

Instead of using len_username – 1 to get the last character, we can use index, -1.

To get the second last character, -2. Keep decreasing the negative number index, to get the characters in reverse.

In the last video, we mainly talked about how iteration could be much easier with while loops since while loops can perform repetitive steps until its condition is false.

There’s another type of iteration called for loops.

A for loop visits each character of a string one at a time, and you can do something at each index or position that you visit.

Using for loops and while loops is called a traversal.

In a while loop, we have a variable that progresses, which eventually makes the while statement condition false.

Let’s say that we wanted to print each character of the username, “microwavesam”, 1 at a time.

index starts at 0 because the starting position is 0 elements away from the first character.

Now, I want to visit every element of microwavesam, so the condition that I want to end my function is when my index is greater than or equal to the length of microwavesam.

When the index is less than len(username), I can print the character at the current index.

Now, I need the index variable to progress, so that it eventually makes the condition false.

This while loop is visiting each character of the username variable.

At each index, we print the character until index is greater than or equal to the length of microwavesam since the last index would be len(username) – 1.

Remember that the last character of a string is len(username) – 1.

This while loop is an example of how a for loop works.

We can do visit every character in “microwavesam” with the for loop.

In this usage of a for loop, the for loop begins with the for keyword.

Then, I left the name of a variable, letter.

in is a keyword that means exactly what it implies.

Using letter in means at each step of the for loop, we are visiting the username’s characters 1 by 1.

In this for loop example, you don’t have to keep track of the condition of stopping at last character.

This for loop automatically will stop after visiting the last character of “microwavesam”.

The second way to do a for loop is by range. Sometimes, you only want to visit a certain number of characters like the first three characters.

Let’s say that I only wanted to visit “mic” from “microwavesam”

We use the for keyword and the in keyword again.

This time I use i as the variable name, short for index.

Then, after the in keyword, I use range(0, 3).

With range, you put the starting number. What will i be at the first step?

Then, each step will by default increase i by 1.

When, the i becomes 3, don’t do the steps in the for loop. The for loop is done.

In this for loop, we start at 0.

Increase i by 1. i = 1.

Increase i by 1. i = 2.

Increase i by 3. When i is 3, exit the for loop.

When we run the program, we will get “m”, “i”, and “c” each on a new line as expected.

If we wanted to print every character of the “microwavesam” with this way of writing a for loop.

We can easily change 3 to len(username).

When we run the program, we get every letter printed out in “microwavesam”.

You would use this type of for loop whenever you want to have more control over each step of your for loop.

For a better example on this for loop’s control, we can print out every other letter.

When you put an additional number inside the parentheses, that number is added to the variable at every step.

i will be increased by 2 at each step, which will allow us to visit every other number.

When we run the program, the for loop will visit every other letter in “microwavesam”.

You can make the range be flexible. We can go in reverse.

For example, we can start at the last index of the string. The last letter of the string.

When we run the program, we visit every character backwards. We start at the last “m”.

len(username) – 1 is the start position.

We are adding -1 to i each step.

When i is -1, we don’t run the statement in the for loop, and the for loop ends.

The third way you can use a for loop is with enumerate. enumerate allows you to get the index and the value as two usable variables.

For example, there are many situations where you’ll need both the index and the value, which is why you would use range.

But sometimes, typing the range may be bothersome, so you can use enumerate like this:

Let’s say that we wanted to print out both the index and value at the index.

You can place two variables that will get the index and value from that index when you use enumerate(username).

These three ways of using for loops provide you with the control to get exactly what you want from every step in the loop.

Now, you might be thinking, why should I use a for loop?

After all, a while loop can do the same thing as any for loop. Why not just remember how to do while loops?

The two main advantages of a for loop are locality and readability.

First, locality.

When we were creating a while loop, we created an index variable in the outside of the while loop.

When we create a for loop the variable is declared inside the for statement.

What happens to the variable declared in the for statement stays within the for loop.

If the variable was created in the outside of the loop like in a while loop, you or someone else might make a mistake in the future and use that variable by accident and cause problems.

Second, being specific. for loops are more readable.

You have a start position and an end position. The start and end positions are clearly defined in the for statement.

We’ve seen that the for statement does initialization, step, and completion condition all in one line.

In a while loop, the while statement has an end condition or completion condition.

The initialization and what to do at each step are located elsewhere.

A while loop is not as quickly readable as a for loop.

A for loop is great for counting up and down like going through each character in “microwavesam” or counting down to the New Year.

A while loop is better for conditions that do not involve counting like the difference between these two doubles must be less than 0.02.

I’m not counting up or down. I’m checking a difference, and I want to keep on tweaking the two numbers until the difference is less than 0.02.

A while loop would be better for that situation.

When you’re counting up and down, visiting through a step by step process that involves incrementing or decrementing numbers, think for loops.

When you have a condition that you must check, and you’re not necessarily counting up or counting down, think while loops.

Now that you understand for loops pretty well, let’s talk about string slicing.

A string slice is a term for a part of a string.

Instead of using a for loop to get the first 3 characters of a string, Python has an abbreviated form using the index numbers.

For example, to get the first 3 characters with string slicing:

Inside the brackets, you put the starting index position, then a colon, then 1 + ending position.

I don’t want to visit the character at index 3 because the character at index 3 is the 4th character.

The first number is inclusive. The second number is non inclusive.

When I run the program, I get “mic” all in one word. String slicing is great for getting entire segments of a string.

It makes getting a continuous part of a string much easier than using a for loop.

Let’s talk about how string are immutable.

Immutable is the term used when something cannot be changed.

In a previous video, we talked about how we could use the addition operator, +, to add two strings together.

A term for adding two strings together is concatenate.

For a string, you cannot change individual letters, which means if I wanted to assign a new letter for a word, I would get an error.

Instead of “microwavesam”, I want “microwavefam”.

When I run the program, I get an error about how the string or object doesn’t support item assignment.

Strings are immutable, which means that portions of a string cannot be reassigned and changed.

A little bit ago, I talked about how for loops are great for counting up and down.

Let’s do a for loop example with a counter.

A counter is a term used often in programming. It’s just a word used for variable that keeps count of something.

We can count the number of “m”‘s in “microwavesam”

We can use variables assigned outside of the for loop inside the for loop.

We can use conditionals like normally inside the for loop.

In this for loop, we check if the current character is equal to “m”.

If the char is equal to “m”, then we increase the count by 1.

When we run the program, we print out the number of “m”‘s, which is 2.

counters are useful variables that keep track of the number of anything inside a loop.

Searching. You can find a segment of a string by using the “in” keyword.

For example,

Using if string in a string can find whether a string is in another string.

“microwave” is inside “microwavesam”, so when we run the program,

“microwave in microwavesam” is printed out.

Instead of just finding a string in a string, we can also see if a string starts or ends with a certain string.

This is very useful if you expect a certain prefix and suffix.

With the .startswith(“”) and .endswith(“”), you can check whether a string starts with or ends with a certain string.

When I run the program, two Trues are printed out because username does start with “microwave”, and it does end with “sam”.

You can check a count of a letter in a string without using a for loop.

When I run the program I get a 2 like we did when using a for loop.

Using .count with a string finds how many of that string is inside “microwavesam”.

There are 2 m’s in “microwavesam”.

There are functions that can change the case like uppercase and lowercase.

Using .lower() makes the string all lowercase.
Using .upper() makes the string all uppercase.
Using .capitalize() makes the first letter capitalized.

Last but not least, there are functions for strings that allow you to replace substrings or take out white space.

You can replace a part of a string with something else. Think of the find and replace feature in most text editors.

When we run the program, “sam” is replaced with “bob”.

Occasionally, you’ll have a string with a lot of whitespace at the end of a string or in the beginning of a string.

You can take out all whitespace by using the .strip function.

When I run the program, all the white space has been stripped from the username variable, and I get “microwavesam”.

Those functions are the main functions that I would use when I have a string.


Video Demonstration

Introduction to Python – Chapter 5 – Iteration and While Loops

We talked about recursion and iteration in the last tutorial.

Recursion is the term used when you call the same function inside a function, which causes repetition since you’re repeating the function.

Iteration is the term used when you repeat steps without using recursion.

This video will be about making iteration or repeating steps easier!

In tutorial #2, we talked about most recent assignment because we talked about how you can assign a variable multiple times.

A variable takes the value of its most recent assignment.

When we’re repeating the assignment of a variable, we are iterating.

When you hear iteration, think repetition.

Let’s say that we set:

Here, we set b = a, and since a’s most recent assignment is 2.

b is equal to 2.

Even though b is equal to a, b is unaffected when we add 1 to a.

b is completely separate from a.

When we add 2 to b’s most recent assignment, we get 2 + 2.

In that example, we were iterating the assignment of a variable.

Instead of writing each repetitive step 1 by 1, Python has statements that make writing iterations or repetitions easy.

We’ll start with the while statement or also called while loop.

The while statement works like a conditional.

When the condition is true, the statements underneath are run, but the difference is that the while statement is checked again, and if the condition is still true, then the statements underneath are run again.

As long as the condition stays true, the statements underneath are repeated.

We use the term while loop because the while statement loops in a circle, repeating its statements.

We can write the same function that did the countdown to New Year’s like we did last video.

The while statement is like an if statements that continually checks the condition after running all the statements underneath.

We start at 10.

num must be greater than 0.

The condition is True, so all the statements underneath are run.

num is equal to 10 – 1.

Now, num is 9.

All the statements tabbed once to the right have been completed.

The while statement checks its condition again.

9 is greater than 0, so the condition stays True.

Repeat all the statements underneath.

Keep on repeating until the condition is false.

The condition is false, when num is 0 because 0 is not greater than 0.

The while statement is similar to recursion, but it doesn’t reuse a function.

There are two main parts.

1. The condition

A while statement is triggered by a True condition like an if statement.

2. Progress

You need to make sure that the condition is eventually False or else, you’ll have an infinite repetition or loop.

For the while loop that we have written, we are constantly decreasing num by 1.

num is decreasing every time we repeat the contents of the while loop.

10 becomes 9, 9 becomes 8, and so on until num is 0. When num is 0, it is not greater than 0, so the while statement ends there.

Then, print(“New Year’s”) happens and afterwards, we’re at the end of the function.

Using iteration with the while statement makes repeating steps much easier than recursion in most cases.

Instead of manually writing print(10) print(9) and so on 1 by 1, the while loop allows us to repeat a series of steps until the condition is False.

In the last video, I told you that if iteration seems easier, then you should use iteration.

But when iteration seems complex, try to think out the solution with recursion to see if recursion will make solving the problem easier.

Let’s do another example,

Let’s make a while loop that prints a number of lines.

First, the function should take in a parameter for the number of lines that we want.

Next, we want to use the while loop. We want to think of a base case. The moment when we are done with the while loop.

We can use num being equal to 0 as a means of ending the while loop.

Step 1 is figuring out our condition. Our condition should be (num != 0) because when num is 0, we are done.

while loops always have the keyword, while, followed by a condition and a colon after the condition.

We want the while loop to print out a line when num is not 0. num starts at 3.

Step 2 is progress. We want num to be decreasing at each step or iteration.

We can subtract num by 1 with each step to make sure that we’re making progress to make the condition eventually false.

The condition will be false when num is equal to 0, so decreasing num by 1 each step makes sense!

We want to print out an empty line at each step because that’s the purpose of our function.

Let’s call out function with the argument 3.

When we run the function, 3 lines are printed out.

Let’s take a closer look at our function.

The argument is 3, so num = 3.

while loop always looks at the while statement and checks if it’s true.

Step 1) the condition. The condition is true because 3 != 0. Do the statements underneath.

3 – 1 = 2

Check condition

2 != 0 is True

2 – 1 = 1

Check condition

1 != 0 is True

1 – 1 = 0

Check condition

0 != 0 is False, so while loop ends here.

While loops make repetitive steps much easier. If you are using repetition, think while loops.

There’s something called infinite while loops. Let’s talk about infinite while loops.

If you forget step 2, progress, then you’ll come out with a while loop that never stops.

If we delete the line, num = num – 1, the while loop will never stop because the condition will always be true.

3 != 0 is always true. num != 0 is always true because num always stays the same. There’s no progress.

The while loops continues forever! On a Windows computer, you can use CTRL-C to end the program.

We want the while loop to end, so always remember that you need progress that will make your condition be false eventually.


Video Demonstration

Introduction to Python – Chapter 4 – Return and Recursion

In this video, we’ll talk about return statements and recursion.

In a previous video, we talked about how the value that you get from a function is the return value.

If I call type(4), I get the return value of int.

How does the type() function return the type int value?

Let’s write a function that adds two numbers and returns the result the same way how the type() function gets a result.

Notice how the function uses the same format that we’ve learned in the last video, but there’s a new line that we haven’t seen before.

What return result does is that it gives the value, result, to where the function called.

The return statement also ends the function.

The reason why I bring up return statements here is that you can use the return keyword inside a conditional, and it ends the function.

Let’s change our function a little bit.

If I were to call add_two_positive_numbers with:

I get the print message, num1 is negative.

I also get a return value of None because return stopped the program after the print(“num1 is negative”).

return can be used to exit the function. If there is no return value, you get a None, which means like it implies: nothingness.

Using returns with conditionals will help you limit your function to a specific behavior like what we did: adding only two positive numbers.

In a previous video, we used a function that we created inside another function.

Whenever we used the print function inside of our functions, we are using a function inside of a function.

Let’s talk about recursion. What is recursion? Recursion is the term used when a function calls itself.

Instead of a function calling a different function, the function calls itself.

A function triggering itself inside the function?

You might be thinking that triggering the function in itself would lead to an infinite loop of the function triggering itself.

You use a conditional that stops the function when you’re ready. A conditional that stops a function calling itself is called the base case.

The base case is the way that a function calling itself can stop.

For example, let’s say that we wanted to make a countdown function celebrating the new year.

We are making a countdown from 10 to 0 for New Year’s!

10, 9, 8, and so on until we get to 0.

When we hit 0, it’s New Year’s, so when num is 0, we stop the function.

If num is not 0, we countdown again bring the num down 1 number.

We start at 10, 10 is not 0, so display the current num, and go to the next num, which is 9.

We are calling countdown function again, but with one less num.

You can notice that there are two main parts to recursion.

The first part is progress.

We make sure that there is some sort of progress every time we use the function again.

In the example, we decrease the number that we’re using by 1.

The number is perpetually decreasing, which means that there is progression towards an end.

The second part is base case.

We make sure that the a base case occurs at our goal. When we countdown from 10, we want to countdown to 0 eventually.

The number 0 is our end goal.

We use a if statement to check if our number is 0 yet, so that we can just stop calling the function over again.

If we don’t call the function, countdown again, the function stops because there is nothing else in that if statement to do except for displaying “New Years!”

Any recursion can be done iteratively. What is iteratively?

Iteratively means repeating a process one at a time. Doing things manually one at a time.

For example,

We are using the print function manually or iteratively one at a time to print three empty lines.

Any iteration can be done recursively and use recursion.

Recursion takes a moment to think about.

Remember that there are two parts.

Part 1) Progress.

Part 2) Base case. The end point.

Decreasing a number or increasing a number is usually a good way to make progress.

The function calling the function must make progress.

A usual base case is checking for 0.

We want to print 3 new lines, so let’s use the number 3 as our argument to act as our starting point.

To make progress, let’s decrease the number 3 each time we use the function.

To end the function, let’s check if the countdown reaches to 0, because if we count from 3 to 0, we should have printed 3 new lines.

Checking if the number is 0 will be our base case, the end point.

3 is greater than 0, print a new line.
3 – 1 = 2

2 is greater than 0, print a new line.
2 – 1 = 1

1 is greater than 0, print a new line.
1 – 1 = 0

0 is not greater than 0, do nothing, which stops the function because there is nothing left to do.

You might be thinking: When do I use recursion and when do I use iteration, writing each line one by one? Why even use recursion?

Recursion is an important concept to understand because some very specific problems are much easier to solve with recursion.

For example, the Fibonacci sequence. Fibonacci numbers are a sequence of numbers in which each number is the sum of the two preceding numbers.

This problem is easier to solve with recursion than iteration. It’s a very specific problem, which happens to be easier to solve with recursion.

The majority of the time if you’re not dealing with a specific type of problem that works well with recursion, you should use iteration instead and write the repeated lines of what you want to do like how we printed 3 new lines by writing print() function 3 times.

Let’s talk about the cons of recursion.

Number 1) For Python, recursion is slower than iteration.

Speed is a huge turn off when using recursion. Think about speed.

Number 2) You may get confused in making your recursive function because often times, you might think hmmmm at step 5,

I am expecting the number to be this, and I think that if the progress keeps happening, the number will be what I expected.

It’s harder to write a good recursive function.

Number 3) Recursion uses more memory.

With all those cons, why would you even use recursion?

The main advantage of recursion is when you have a very specific problem that has a point A and a point B, and you need to get to point B, but to get to point B requires a large number of complex repetitive steps.

Recursion might be for you. In this very specific situation like Fibonacci numbers, recursion is absolutely the choice to use.

I would recommend to Google for some advice to see if recursion would be great for your very specific problem.

The ultimate rule to is if you ever think that writing your steps iteratively is hard, see if recursion will be easier.

If writing your steps iteratively is easy, then use iteration.

For example, in our countdown problem, counting down from 10 to 0, it’s easy to make.

We can easily print the countdown from 10 to 0. Since it’s easy to make, we should use iteration.

We learn recursion because you will encounter those very specific problems where recursion is the best or only way to solve the problem!

The last topic that we’ll talk in this video is infinite recursion.

Infinite recursion is the term used whenever the function keeps calling itself and never stops.

There’s no base case. There’s no end point.

For example,

We can write a new function:

There is no if statement base case that stops the program. All this program does is call itself again and again and again.

Python has an error called Maximum recursion depth exceeded that stops the function from calling itself infinite times.

If there was no Python error to stop the recursive function, the function would call itself until we wouldn’t have any more memory.


Video Demonstration