The program is written in Python and performs the following operations:
The final output of the program will be the sum of all the first positions of the nested tuples. The while loop will keep accessing the first position of the current nested tuple, adding it to the "res" variable, and then moving to the next nested tuple until there are no more nested tuples.
val = (1, (2, (3, (4, (5, None))))) print("Tuple : ",val) res = 0 while val: res += val[0] val = val[1] print("Summation of 1st positions : " ,res)
Tuple : (1, (2, (3, (4, (5, None))))) Summation of 1st positions : 15
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions