- 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
![Gireesha Devara](https://www.tutorialspoint.com/assets/profiles/397483/profile/60_1063327-1637125522.jpg)
6K+ Views
A tuple is a collection of objects which ordered and immutable. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets. There are three different ways we can convert a python tuple to string. Using a for loop. Using the python join() method Using the functool.reduce() method Using the for loop In python, we can easily iterate the tuple elements using the for loop, then we will append/add each element to the string object. In this below example we ... Read More
![Pythonic](https://www.tutorialspoint.com/assets/profiles/15007/profile/60_156531-1514381552.jpg)
237 Views
In Python 2.x, both methods are available, but in Python 3.x iteritems() is deprecated. As far as Python 2.x is concerned, items() method of dictionary object returns list of two element tuples, each tuple containing key and value. On the other hand iteritems() is a generator which provides an iterator for items in a dictionary >>> d = {'1': 1, '2': 2, '3': 3} >>> d.items() [(1, 1), (2, 2), (3, 3)] >>> for i in d.iteritems(): print i ('1', 1) ('2', 2) ('3', 3) In Python 3, items() method behaves ... Read More
![Gireesha Devara](https://www.tutorialspoint.com/assets/profiles/397483/profile/60_1063327-1637125522.jpg)
622 Views
In Python, using a for loop is common to iterate a single data structure like list, but what if we need to iterate two/multiple lists parallelly?. In this article we will see different ways to iterate two/multiple lists parallelly. By using range() function, we can iterate the two lists parallelly. Lets see the below examples and how we are going to iterate two lists in python. Using the for loop If length of the two lists are same Assuming that both lists have the same length, here we are using the len() method to get the length of ... Read More
![Gireesha Devara](https://www.tutorialspoint.com/assets/profiles/397483/profile/60_1063327-1637125522.jpg)
6K+ Views
To convert a string represented dictionary to an original dictionary we can use built-in functions like eval(), json.load(), and ast.literal_eval(). Initially, we must ensure that the string contains a valid representation of the dictionary. Let’s discuss how each function will convert the string representation of a dictionary to an original dictionary. Using the eval() function The eval() is a python built-In function that takes a string argument, parses it as a code expression, and evaluates the expression. If the input expression contains a string representation of a dictionary, then the eval() method returns it as a normal Python dictionary. ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/7345/profile/60_93814-1511173378.jpg)
244 Views
The best way is to use not operator on list object. If list is empty it returns true, otherwise false.>>> L1=[] >>> not L1 True >>> L1=[1,2] >>> not L1 FalseAnother method is to check if length of list is zero which means it is empty>>> L1=[] >>> len(L1) 0 >>> L1=[1,2] >>> len(L1) 2
![Gireesha Devara](https://www.tutorialspoint.com/assets/profiles/397483/profile/60_1063327-1637125522.jpg)
427 Views
Python is being updated regularly with new features and supports. Starting from 1994 to current release, there are lots of updates in Python versions. By using Python standard libraries like sys or platform modules we can get the version information of Python that is actually running on our script. In general the python version is displayed automatically on the console immediately after starting the interpreter from the command line. Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. Using the version attribute The sys ... Read More
![Gireesha Devara](https://www.tutorialspoint.com/assets/profiles/397483/profile/60_1063327-1637125522.jpg)
567 Views
In Python lists are one the built−in data structure which is used to store collections of data. The lists are mutable, which means we can modify its element after it is created. We have some list methods like append, insert, extend, remove, and clear which are used to change the list content by adding, updating, or removing elements from the list object. In this article, we will discuss how we can update an existing element in the list. Updating the list elements using the index position The list is an index−based sequential data structure, so that we can access the ... Read More
![Gireesha Devara](https://www.tutorialspoint.com/assets/profiles/397483/profile/60_1063327-1637125522.jpg)
1K+ Views
Python tuple is an immutable object, which means once tuple is created you cannot change, update, add, or remove its values. If we try to update any of its elements, then it will throw the TypeError. In this article, we will use three different ways like list conversion, slicing, packing, and unpacking to modify a tuple without raising any errors. Using list conversion By converting tuple to a list then converting it back, we can update the values in tuple, but this will create a list copy of tuple in memory. Example After converting the tuple to list, we ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
191 Views
A python object or variable will be eligible for garbage collection as soon as all references to it go out of scope or are manually deleted (del x). We would have to presume there were no references to the object anywhere else for it to be garbage collected.