Tuples have only two built-in methods: count()
and index()
. Tuples are immutable, so no method can change their content.
Tuple में सिर्फ दो built-in methods होते हैं: count()
और index()
। Tuple immutable होता है, इसलिए इसे modify करने वाला कोई method नहीं होता।
Returns how many times an item appears in the tuple.
Tuple में कोई value कितनी बार repeat हुई है, यह return करता है।
names = ("Aryan", "Abhishek", "Aryan", "Jayati", "Aryan")
print(names.count("Aryan"))
Output:
3
Returns the index of the first matching value.
Tuple में कोई value सबसे पहले कहाँ है, उसका index return करता है।
students = ("Chaitanya", "Naincy", "Shrutika", "Jayati")
print(students.index("Shrutika"))
Output:
2