Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
335 views
in Python by (178k points)
Can tuples contain duplicate values?

Please log in or register to answer this question.

1 Answer

0 votes
by (178k points)

Yes, tuples can contain duplicate values in Python. Unlike sets, tuples allow duplicate values to be present in them. You can define a tuple with duplicate values by simply listing the values separated by commas, just like any other tuple.

For example, consider the following tuple:

my_tuple = (1, 2, 3, 2, 4, 1)
 

In this tuple, the values 1 and 2 appear twice. This is perfectly valid in Python, and you can access these values using indexing or slicing.

print(my_tuple[0])  # Output: 1
print(my_tuple.count(2))  # Output: 2
 

Here, the count() method returns the number of times a specific value appears in the tuple. In this case, the value 2 appears twice, so the count() method returns 2.

Related questions

0 votes
1 answer
asked Mar 21, 2023 in Python by kvdevika (178k points)
0 votes
1 answer
0 votes
2 answers
asked Mar 21, 2023 in Python by kvdevika (178k points)
0 votes
1 answer
asked Mar 22, 2023 in Python by kvdevika (178k points)

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...