- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10784 Articles for Python
239 Views
In this article, we will learn how to remove all digits before a given number in python. Methods Used The following are the various methods to accomplish this task − Using List Comprehension, split(), enumerate() & index() Functions Using re module Using slicing, index() & replace() functions Example Assume we have taken an input string and an input number. We will now remove all the digits before the input number from an input string. Input inputString = 'hello 6 8 10 tutorialspoint 15 python codes' inputNumber = 10 Output Resultant string after removing digits before input number{ ... Read More
875 Views
In this article, we will learn how to convert characters to uppercase in Strings Randomly using python. Methods Used The following are the various methods to accomplish this task − Using join(), choice(), lower(), upper() functions. Using random.randInt() and random.sample() functions. Using map(), choice(), zip() functions Example Assume we have taken an input string. We will now randomly convert the characters of an input string to uppercase using the above methods. Input inputString = 'tutorialspoint' Output String after converting chars lower or uppercase randomly: tUToriaLsPOINT In this example, We are converting characters of an input ... Read More
638 Views
In this article, we will learn a python program to move numbers to the end of the string. Methods Used The following are the various methods to accomplish this task − Using isdigit() and for loop Using isdigit() and join() functions Without using any built-in functions Using isnumeric() function Using isalpha() function Example Assume we have taken an input string. We will now move all the numbers contained in an input string to the end of the string using the above methods. Input inputString = 'hello5691 tutorialspoint1342' Output Resultant string after adding digits at the end: hello ... Read More
326 Views
In this article, we will learn how to join strings by multiple delimiters in python. Methods Used The following are the various methods to accomplish this task − Using List Comprehension and “+” Operator Using List Comprehension and join() Function Example Assume we have taken two input strings and a multiple delimiters list. We will now join both the input strings with the given input delimiters and returns a resultant list using the above methods. Input Input String 1: hello Input String 2: tutorialspoint delimitersList = ["-", "^", "%", "$", "#"] Output Both the strings after joining ... Read More
503 Views
In this article, we will learn how to get word frequency in percentage in python. Assume we have taken an input list of strings. We will now find the percentage of each word in the given input list of strings. Formula (Occurrence of X word / Total words) * 100 Methods Used Using sum(), Counter(), join() and split() functions Using join(), split() and count() functions Using countOf() function from operator module. Method 1: Using sum(), Counter(), join() and split() functions join() is a string function in Python that is used to join elements of a sequence ... Read More
2K+ Views
In this article, we will learn a python program to find the sum of dictionary keys. Methods Used The following are the various methods to accomplish this task − Using for loop Using dict.keys() and sum() functions Using reduce() function Using items() function Example Assume we have taken an input dictionary containing some random key-value pairs. We will now find the sum of all the keys of an input dictionary using the above methods. Input inputDict = {4: 10, 1: 30, 10: 50, 2: 70, 8: 90} Output Sum of keys of an input dictionary: 25 ... Read More
3K+ Views
In this article, we will learn a python program to find the sum of characters' ASCII values in a list of strings. Methods Used The following are the various methods to accomplish this task − Using for Loop, + operator, ord() function Using list Comprehension, sum(), ord() functions Example Assume we have taken an input list containing string elements. We will find the @@ Input Input List: ['hello', 'tutorialspoint', 'python', 'platform'] Output [52, 209, 98, 101] Here, The ASCII values of all the characters of each list element like hello is 8+5+12+12+15 = 52 where ASCII ... Read More
219 Views
In this article, we will learn how to extract strings with a digit in python. Methods Used The following are the various methods to accomplish this task − Using list comprehension, any() and isdigit() functions Using any(), filter() and lambda functions Without using any built-in functions Using ord() function Example Assume we have taken an input list containing strings. We will now extract strings containing a digit in an input list using the above methods. Input inputList = ['hello562', 'tutorialspoint', 'python20', 'codes', '100'] Output List of Strings containing any digits: ['hello562', 'python20', '100'] In the above ... Read More
6K+ Views
In this article, we will a python program to count the number of spaces in a string. Methods Used The following are the various methods to accomplish this task − Using for loop (with indexing) Using count() function Using isspace() function Using Counter() function Using countOf() function of the operator module Assume we have taken an input string. we will now count the number of spaces in an input string above methods. Method 1: Using for loop (with indexing) Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task –. Create a function ... Read More
1K+ Views
In this article, we will learn how to count Words with a specific letter in a string in python. Methods Used The following are the various methods to accomplish this task − Using list comprehension, len() & split() functions Using split() & find() functions Using split(), replace() & len() functions Using Counter() function Example Assume we have taken an input string and some random character. We will now count the words that contain the given input character in an input string. Input inputString = 'hello tutorialspoint python codes' inputChar = "p" Output Count of words containing the ... Read More