Home » Programming » Python

Concatenating (Joining) Strings in Python

string concatenation python

Let’s look at two ways you can concatenate (which is a fancy word for join or merge) two or more strings in Python. It’s also worth checking out our article on converting integers to strings in Python. A Note On Immutable Strings Strings in Python are immutable and cannot be changed once defined. This means that whenever you join two strings, a new string is created (ie. the original is not modified!). This has both performance side effects and affects how you should structure your code: … Read more

Home » Programming » Python

Escape Characters in Python, With Examples

Escape Characters in Python

Every programming language has special characters that trigger certain behaviors in your code – and Python is no exception. These characters cannot be used in strings (as they are reserved for use in your code) – and must be “escaped” to tell the computer that the character should just be treated as a regular piece of text rather than something that needs to be considered while the code is being executed. If you want to be able to leave yourself notes in your code, check … Read more

Home » Programming » Python

How To Remove Items From A List in Python (With Examples)

python remove items from list

Python is widely used for both scripting and automation on Linux, as well as building web and standalone applications. Python is designed to be easy to learn, easy to write, and easy to read. It’s a great multi-purpose programming language. Python has several different types of arrays for storing data. Lists are arrays which allow you to store items. Items in lists can be altered, and are stored in a specific order. Syntax and Examples There are several methods you can use to remove an … Read more

Home » Programming » Python

How to Make Multiline Comments in Python

How to make multi line comments in Python

In this tutorial, we explain the two methods used to make multiline comments in Python, with examples. There are some drawbacks to one of the methods, so pay attention. Code without comments is like a story written in a language you only half understand. You might be able to figure out the main points, but you’ll miss some nuances and it would be way easier with a translation alongside it. Most coders hate code with no comments or limited comments, so finding ways to clearly … Read more

Home » Programming » Python

Python: How to Check Whether a File or Directory Exists

Python How to check whether a file or directory exists

In this article, we explain how to check whether a file or directory exists in Python and include some useful examples to help you get started. Python is a high-level programming language with dynamic semantics. Developed in the early 90s, and named after the Monty Python comedy troupe, it uses simple, easy-to-learn syntax and remains very popular amongst the programming community. It is particularly attractive for Rapid Application Development (RAD) and for its ability to connect existing components together. Python can be used for: server-side … Read more

Home » Programming » Python

How to Convert a String to int in Python (and Int to String)

how to convert string int python 1

This article explains how to convert a string into an integer in Python. When you are looking to program with Python, it’s essential that you are aware of the different data types that you may be dealing with. The way your data is stored will depend on which kind of data it is and each kind of data operates in a different manner. Different data types in Python Data types that you’re likely to encounter fall under the categories of numeric, string, and boolean. Simply … Read more

Home » Programming » Python

How to Use Split in Python to Split a String

python logo

Python is the world’s second most popular programming language and is the preferred choice of many programmers. It is particularly useful for backend web development, artificial intelligence, data analysis, and scientific computing, but can also be used for creating games and desktop apps. One of the most common questions when it comes to Python is how to split a string. A string in Python is a sequence of Unicode characters, and string variables can be very helpful for Python programmers. They can contain alphanumeric or … Read more