Python Articles

Page 824 of 855

FuzzyWuzzy Python library

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 866 Views

In this tutorial, we are going to learn about the FuzzyWuzzy Python library. FuzzyWuzzy library is developed to compare strings and provides fuzzy string matching capabilities. While we have other modules like regex and difflib to compare strings, FuzzyWuzzy is unique in its approach. The methods from this library return a score out of 100 indicating how closely the strings match, instead of simple true/false or string results. Installation To work with the FuzzyWuzzy library, we need to install fuzzywuzzy and optionally python-Levenshtein for better performance − pip install fuzzywuzzy pip install python-Levenshtein The ...

Read More

Print anagrams together in Python using List and Dictionary

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 777 Views

In this tutorial, we will write a program to find and print anagrams together using list and dictionary. Anagrams are words formed by rearranging the letters of another word, like "listen" and "silent". Algorithm Here's our step-by-step approach ? 1. Initialize a list of strings. 2. Initialize an empty dictionary. 3. Iterate through the list of strings. 3.1. Sort the string and check if it is present in the dictionary as key or not. 3.1.1. If the sorted string is already present dictionary as a ...

Read More

Print first m multiples of n without using any loop in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 823 Views

In this tutorial, we will write a program to find the first m multiples of a number n without using loops. For example, if n = 4 and m = 3, the output should be 4, 8, 12 (three multiples of four). The main constraint is avoiding loops. We can use the range() function to achieve this without loops. The range() function returns a range object that generates a sequence of numbers. Syntax range(start, stop, step) Parameters start − Starting number of the range stop − Ending number (not included in the ...

Read More

Python program to count occurrences of a word in a string

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 4K+ Views

In this tutorial, we will write a program that counts the number of times a word occurs in a string. You are given a word and a string, and we need to calculate the frequency of the word in the string. Suppose we have a string "I am a programmer. I am a student." and the word "am". The program will return 2 as the word occurs two times in the string. Algorithm 1. Initialize the string and the word as two variables. 2. Split the string at spaces using the split() method to get a ...

Read More

Python program to find the IP Address of the client

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 61K+ Views

In this tutorial, we are going to find the IP address of the client using the socket module in Python. Every laptop, mobile, tablet, etc., has their unique IP address. We will find it by using the socket module. Let's see the steps to find out the IP address of a device. Algorithm Import the socket module. Get the hostname using the socket.gethostname() method and store it in a variable. Find the IP address by passing the hostname as an argument to the socket.gethostbyname() method and store it in a variable. Print the IP address. ...

Read More

Sort a list according to the Length of the Elements in Python program

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 6K+ Views

We have a list of strings and our goal is to sort the list based on the length of strings in the list. We have to arrange the strings in ascending order according to their lengths. We can do this using Python built-in method sort() or function sorted() along with a key. Let's take an example to see the output − Input: strings = ["hafeez", "aslan", "honey", "appi"] Output: ["appi", "aslan", "honey", "hafeez"] Using sorted() Function The sorted() function returns a new sorted list without modifying the original list. We pass len as ...

Read More

Reverse words in a given String in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 19K+ Views

We are given a string, and our goal is to reverse all the words which are present in the string. We can use the split() method and reversed() function to achieve this. Let's see some sample test cases. Input: string = "I am a python programmer" Output: programmer python a am I Input: string = "tutorialspoint is a educational website" Output: website educational a is tutorialspoint Python provides multiple approaches to reverse words in a string. Let's explore the most common methods. Method 1: Using split() and reversed() This approach splits ...

Read More

How to run Python code on Google Colaboratory?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 954 Views

Google Colaboratory (Colab) is a free Jupyter notebook environment that requires no setup and runs entirely in the cloud. It is hosted in Google Cloud and maintained by Google, allowing Python developers to write, run, and share code using a web browser. In this article, we will learn how to set up and use Google Colab for Python programming. Accessing Google Colab Navigate to the Google Colab website at https://colab.research.google.com/. You'll see the welcome screen with options to create a new notebook or open existing ones from various sources like GitHub, Google Drive, or upload from your computer. ...

Read More

getpass() and getuser() in Python (Password without echo)

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

The getpass module in Python provides secure password input functionality without displaying typed characters on screen. This is essential for applications requiring password authentication where you need to hide sensitive input from shoulder surfing or screen recording. Basic Password Input with getpass() The getpass() function prompts for a password and reads input without echoing it to the terminal ? import getpass try: pwd = getpass.getpass() except Exception as err: print('Error Occurred:', err) else: print('Password entered:', pwd) The output of the above ...

Read More

Few mistakes when using Python dictionary

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 333 Views

Dictionaries in Python are a data structure that maps keys to values as key-value pairs. They are one of the most frequently used data structures and have many useful properties. However, there are several common mistakes developers make when working with dictionaries that can lead to errors or unexpected behavior. Basic Dictionary Operations Before exploring common mistakes, let's review basic dictionary operations ? # Creating a dictionary days_dict = {'day1': 'Mon', 'day2': 'Tue', 'day3': 'Wed'} print(type(days_dict)) print(days_dict) # Using the dict() constructor days_dict2 = dict([('day1', 'Mon'), ('day2', 'Tue'), ('day3', 'Wed')]) print(days_dict2) ...

Read More
Showing 8231–8240 of 8,546 articles
« Prev 1 822 823 824 825 826 855 Next »
Advertisements