This Python substring tutorial covers retrieving substrings from strings. Remember that a substring is simply a part of a bigger string. Since Python treats strings as arrays, we can manipulate strings using array notation to retrieve substrings. This method is also called string slicing.
Getting substrings are useful when parsing data, for example to pull a certain number of characters from a string. Whatever your need for finding substrings is, the Python substring tutorial below will get you up to speed on using substrings in Python.
The Python if statement is just a regular conditional statement (similar to conditional statements in other languages) which allows your program to make decisions based on the result of the specified condition.
In this Python tutorial, we will look at the syntax of the Python if statement and how to use it in your Python scripts to make decisions and make your scripts smarter.
The Python tutorial below explains.
The syntax of the if statement in Python is shown below. As shown, it can be used for multiple conditions:
In this tutorial, you will learn how to run Python scripts in Ubuntu using the terminal. The process basically involves invoking the Python interpreter and passing the name of the Python script to be executed as an argument to it.
This tutorial also covers how to install Python if it is not currently installed on your system.
So if we wanted to use the terminal to invoke a Python script called helloworld.py which was in the current working directory we would do it like this: