Author: Arpit Mandliya
- 27 November
Remove Punctuation from List in Python
Use for loop with replace() Method To remove punctuation from list in Python: Use the for loop to iterate over each word (element) of given list. Use a nested loop to iterate over each character in the word. Use the if statement to check if the current character is in string.punctuation, if it is use […]
- 27 November
Print Environment Variables in PowerShell
💡TL;DR To print environment variables in PowerShell, use Get-ChildItem cmdlet as below: [crayon-67bd2b42870fe738732625/] Environment variables store values used by the operating system and installed programs. For instance, the environment variable PATH contains a list of directories to search for executable files. Some other environment variables in the Windows operating system are OS, APPDATA, COMPUTERNAME, USERNAME, […]
- 26 November
Add Character to String in PHP
Strings are a sequence of characters considered immutable (unchanging once created). But how do we add characters to strings in PHP? This post will explain how to add characters to a string in PHP. PHP provides different built-in methods and approaches to add a character to a string. Importantly, the string will not be changed […]
- 26 November
Remove Empty Lines from Text File in Python
Use isspace() Method To remove empty lines from a Text File in Python: Open a file in read and write mode(r+). Use for loop for iterate over each line in the file. Use isspace() method to check if line is empty. if it is not empty, add it to result. Use seek(0) to move cursor […]
- 25 November
Check if Variable Is None in Python
In Python, Check if Variable Is None and Check if Variable Is null have same solutions as meaning of both queries is same. 1. Introduction In Python Programming, checking when a variable is None(Python equivalent of null or nil in other languages) is a common task, particularly in functions returning no value, handling optional parameters […]
- 25 November
Print String Till Character in Python
A string can be termed as a collection of characters with each character occupying a particular position. Strings cannot be altered and are considered immutable in Python. Print String Till Character in Python This tutorial will demonstrate how to print string till character in Python. Using the for loop and break statement A string can […]
- 25 November
Remove NewLine from String in Python
1. Introduction Removing newline characters from strings is a common task in Python, especially in text processing and data cleaning. However, newline characters can vary across different operating systems: Unix-like systems (including Linux and macOS) use \n (Line Feed), while Windows uses \r\n (Carriage Return and Line Feed). Therefore, a solution that works uniformly across […]
- 24 November
Print Methods of Object in Python
💡 TL;DR To get all methods of object, use inbuilt dir() method [crayon-67bd2b4287f09296139919/] Working with Python methods and attributes is very easy but seems challenging when we want to know if a specific object has a particular method/attribute or not. This tutorial teaches the use of dir(), and inspect.getmembers() to print all methods of a […]
- 24 November
Print Variable and String in Same Line in Python
💡 TL;DR To Print Variable and String in Same Line in Python, use print() method and separate String and variable with comma. [crayon-67bd2b42882ba050772857/] Print Variable and String in Same Line in Python We use the print() function in Python to display output. It was changed to a function in Python and existed as a statement […]