
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Define Duplicate Items in a Python Tuple
You can directly enter duplicate items in a Python tuple as it doesn't behave like a set(which takes only unique items).
example
myTpl = (1, 2, 2, 2, 3, 5, 5, 4)
You can also use operators on tuples to compose large tuples.For Example
myTpl = (1,) * 5 print(myTpl)
Output
This will give the output
(1,1,1,1,1)
You can also join tuples using + operator.
example
myTpl = (1,) * 3 + (2,) * 2 print(myTpl)
Output
This will give the output
(1,1,1,2,2)
Advertisements