টিপল আনপ্যাকিং সংজ্ঞায়িত করার আগে আমাদের বুঝতে হবে টিপল কি।
টুপল :পাইথনে টিপলগুলি অপরিবর্তনীয় বস্তু সংরক্ষণ করতে ব্যবহৃত হয়। একটি টিপল হল অপরিবর্তনীয় পাইথন বস্তুর একটি ক্রম। Tuples হল সিকোয়েন্স, tuples পরিবর্তন করা যায় না এবং tuples বন্ধনী ব্যবহার করে। এটি (RHS) মানগুলির ডান দিকের (LHS) বাম দিকের দিকে বরাদ্দ করে। অন্যভাবে একে ভেরিয়েবলে মানের একটি টুপল আনপ্যাক করা বলা হয়। টিপল আনপ্যাক করার সময় এলএইচএস-এ ভেরিয়েবলের সংখ্যা প্রদত্ত টিপলের মানের সংখ্যার সমান হওয়া উচিত। প্যাকিং-এ, আমরা মানগুলিকে একটি নতুন টিপলে রাখি যখন আনপ্যাক করার সময় আমরা সেই মানগুলিকে একটি একক পরিবর্তনশীলে বের করি৷
উদাহরণ 1
tuple = ("Tutorials Point", 132, "Employees") # tuple packing
(companyname , Employerscount ,Information) = tuple # tuple unpacking
print(companyname)
print(Employerscount)
print(Information) আউটপুট
Tutorials Point 132 Employees
উদাহরণ 2
tuple = ("RRS College of Engg and Technology", 6000, "Engineering") # tuple packing
(college, student, graduates) = tuple # tuple unpacking
# print college name
print(college)
# print no of student
print(student)
# print type of college
print(graduates) আউটপুট
RRS College of Engg and Technology 6000 Engineering