Python is a popular programming language that is widely used for various purposes. However, sometimes you may encounter an error message that says “SyntaxError: EOL while scanning string literal”. This error message can be confusing, especially for beginners. In this tutorial, we will explain what this error message means and how to fix it. What …
String
In this tutorial, we will look at how to swap two digits in a number in Python with the help of some examples. If you prefer video over text, check out the following video detailing the steps in this tutorial – Steps to swap digits in a number You can use the following steps to …
In this tutorial, we will look at how to replace single quotes in a Python string with double quotes with the help of some examples. Replace ‘ with ” inside a string Let’s see an example to better understand the task at hand. Let’s say you have the string, “This is a ‘safe’ place”. After …
In this tutorial, we will look at how to swap the case of a Python string with the help of some examples. What does it mean to swap the case of a string? Swapping the case in a string refers to changing lowercase letters in the string to uppercase and uppercase letters in the string …
In this tutorial, we will look at how we can swap adjacent characters in a string. Let’s look at an example to better understand the task at hand. Swapping adjacent characters example Let’s say you have the string, “heat”, after swapping the adjacent characters, the string becomes “ehta”. Here, we’re swapping the ith character in …
In this tutorial, we will look at how to swap two words in a string in Python with the help of some examples. If you prefer a video tutorial over text, check out the following video detailing the steps in this tutorial. How is swapping words different from replacing words in a String? Note that …
In this tutorial, we will look at how to swap two characters in a Python string with the help of some examples. Can you change characters in a Python string in place? No. Strings in Python are immutable so you cannot modify a string after it has been created, you can, however, create a new …
In this tutorial, we’ll try to understand how to search and replace all occurrences of a text in a file using Python in two different ways. Method 1 – Search and replace text in a different file In this method, We first open the input file in read mode and open a new file in …
In this tutorial, we will look at how to check if the user input in Python is empty or not with the help of some examples. How to check if user input is empty? Values from the standard input are read as strings in Python. So, to check if the input is empty use the …
In this tutorial, we will look at how to check if a user input in Python is a number or not with the help of some examples. How to check if the user input is a number? In Python, we receive the value from the standard input as strings. Now, to check if the input …