- 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
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
10K+ Views
We can pass re.IGNORECASE to the flags parameter of search, match, or sub −Example import re print (re.search('bush', 'BuSh', re.IGNORECASE)) print (re.match('bush', 'BuSh', re.IGNORECASE)) print (re.sub('bush', 'xxxx', 'Bushmeat', flags=re.IGNORECASE))Output xxxxmeat
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
10K+ Views
To extract decimal numbers from a string in Python, regular expressions are used. A regular expression is a group of characters that allows you to use a search pattern to find a string or a set of strings. RegEx is another name for regular expressions. The re module in Python is used to work with regular expressions. In this article, we will get to know how to extract decimal numbers from a string in python using regular expressions. We use \d+\.\d+ regular expression in python to get non digit characters from a string. Where, \d returns a match where ... Read More
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
56K+ Views
In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In this article, we will show you how to check if the given input list is an empty list or NOT using python. Below are the 5 methods to accomplish this task − Using not operator Using len() function By Comparing with an Empty List Using __len__() Using NumPy Module Assume we have taken an empty list. We will check if the input list is empty or not and returns some random message for acknowledgment using different methods ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
249 Views
A nested list is a list which has elements as lists itself. For example: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] is a nested list as it has 3 lists ([1, 2, 3], [4, 5, 6], and [7, 8, 9]) as its elements. To flatten a list of lists (nested list) i.e., to convert a 2D list into a 1D list, there are different ways such as nested for loop, list comprehension, built-in functions or by importing libraries in python. In this article we will discuss the above methods to flatten a list in Python. Using for loops ... Read More
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
434 Views
Python includes a built-in package i.e random module for generating random numbers. In this article, we will show you how to generate random numbers in python using different methods − Using random.seed() method Using random.randrange() method Using random.randint() method Using random.random() Using random.choice() method Using random.uniform() method Method 1: Using random.seed() method The random number generator is initialized using the seed() method. To generate a random number, the random number generator requires a starting numeric value (a seed value). NOTE − The random number generator utilizes the current system time by default. To change the random number generator's ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
6K+ Views
Python is not a "statically typed" programming language. We do not need to define variables or their types before utilizing them. Once we initially assign a value to a variable, it is said to be created. Each variable is assigned with a memory location. The assignment operator (=) assigns the value provided to right to the variable name which is at its left. Syntax The syntax of the assignment operator is shown below. var_name = value Example The following is the example which shows the usage of the assignment operator. Name = ‘Tutorialspoint’ In Python, variable is really ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
5K+ Views
In this article we will discuss different ways to assign values to variables in a list using loops in python. Using simple loop iterations In this method we use the for loop for appending elements into the lists. When we do not enter any element into the list and stop appending, then we just press the enter key. To append the elements into the list we use the append() method. Example 1 The following is an example to assign values to the variables in a list using a loop in python using append() method. L=[] while True: ... Read More
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
35K+ Views
The Python tuple elements are enclosed inside the parenthesis, while dictionary elements are present in the form of a key-value pair and are enclosed between curly brackets. In this article, we will show you how to convert a Python tuple into a dictionary. The following are the methods to convert a tuple into a dictionary − Using dict() function Using Dictionary Comprehension and enumerate() function Using zip() and dict() functions Assume we have taken a tuple containing some elements. We will convert the input tuple into a python dictionary and return it using different methods as specified above. ... Read More
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
857 Views
Python provides a variety of data structure collections such as lists, tuples, sets, and dictionaries. However, these tuples are very similar to lists. Because lists are a commonly used data structure, developers frequently mistake how tuples differ from lists. Python tuples, like lists, are a collection of items of any data type, but tuples are immutable, which means that once assigned, we cannot change the elements of the tuple or the tuple itself, whereas list elements are mutable In this article, we will explain to you what is a tuple in python and the various operations on it. Creating a ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
267 Views
Index in python refers to the position of the element within an ordered list. The starting element is of zero index and the last element is of n 1 index where n is the length of the list. In this tutorial, we will look at how to find out the index of an element in a list in Python. They are different methods to retrieve the index of an element. Using index() method Three arguments can be passed to the list index() method in Python − element − element that has to be found. start (optional) − Begin your ... Read More