- 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
Mohd Mohtashim has Published 251 Articles
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
7K+ Views
Removing individual tuple elements is not possible. There is, of course, nothing wrong with putting together another tuple with the undesired elements discarded.To explicitly remove an entire tuple, just use the del statement.Example Live Demo#!/usr/bin/python tup = ('physics', 'chemistry', 1997, 2000); print tup; del tup; print "After deleting tup : "; print tup;OutputThis ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
8K+ Views
To access values in tuple, use the square brackets for slicing along with the index or indices to obtain value available at that index.Example Live Demo#!/usr/bin/python tup1 = ('physics', 'chemistry', 1997, 2000); tup2 = (1, 2, 3, 4, 5, 6, 7 ); print "tup1[0]: ", tup1[0]; print "tup2[1:5]: ", tup2[1:5];OutputWhen the ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
19K+ Views
Python includes the following list functions −Sr.NoFunction with Description1cmp(list1, list2)Compares elements of both lists.2len(list)Gives the total length of the list.p>3max(list)Returns item from the list with max value.4min(list)Returns item from the list with min value.5list(seq)Converts a tuple into list.Python includes following list methodsSr.NoMethods with Description1list.append(obj)Appends object obj to list2list.count(obj)Returns count of ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
1K+ Views
Lists respond to the + and * operators much like strings; they mean concatenation and repetition here too, except that the result is a new list, not a string.In fact, lists respond to all of the general sequence operations we used on strings in the prior chapter.Python ExpressionResultsDescriptionlen([1, 2, 3])3Length[1, ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
336 Views
To remove a list element, you can use either the del statement if you know exactly which element(s) you are deleting or the remove() method if you do not know.Example Live Demo#!/usr/bin/python list1 = ['physics', 'chemistry', 1997, 2000]; print list1 del list1[2]; print "After deleting value at index 2 : " ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
347 Views
To access values in lists, use the square brackets for slicing along with the index or indices to obtain value available at that index.Example Live Demo#!/usr/bin/python list1 = ['physics', 'chemistry', 1997, 2000]; list2 = [1, 2, 3, 4, 5, 6, 7 ]; print "list1[0]: ", list1[0] print "list2[1:5]: ", list2[1:5]OutputWhen the ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
3K+ Views
Python includes the following built-in methods to manipulate strings −Sr.NoFunction & Description1capitalize()Capitalizes first letter of string2center(width, fillchar)Returns a space-padded string with the original string centered to a total of width columns.3count(str, beg= 0, end=len(string))Counts how many times str occurs in string or in a substring of string if starting index ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
3K+ Views
Normal strings in Python are stored internally as 8-bit ASCII, while Unicode strings are stored as 16-bit Unicode. This allows for a more varied set of characters, including special characters from most languages in the world. I'll restrict my treatment of Unicode strings to the following −Example Live Demo#!/usr/bin/python print u'Hello, ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
6K+ Views
Python's triple quotes comes to the rescue by allowing strings to span multiple lines, including verbatim NEWLINEs, TABs, and any other special characters.The syntax for triple quotes consists of three consecutive single or double quotes.Example Live Demo#!/usr/bin/python para_str = """this is a long string that is made up of several lines and non-printable ... Read More
![Mohd Mohtashim](https://www.tutorialspoint.com/assets/profiles/152429/profile/60_230655-1575021953.jpg)
Mohd Mohtashim
2K+ Views
Assume string variable a holds 'Hello' and variable b holds 'Python', then −Sr.NoOperator & DescriptionExample1+Concatenation - Adds values on either side of the operatora + b will give HelloPython2*Repetition - Creates new strings, concatenating multiple copies of the same stringa*2 will give-HelloHello3[]Slice - Gives the character from the given indexa[1] ... Read More