So I'm having trouble with printing out the largest number of a nested tuple. Let me backtrack here a bit. So I got a really good idea of how to separately print out elements, how to assign separated elements into a new tuple, and how to print out the largest number of a regular tuple. Well, I was given a challenge not that long ago that wants me to write a program that prints out the largest number of a nested tuple. At first, I thought this might be easy, but I keep printing out the same variables. Let me show you what I have so far.
my_nested_tuple = ((2,12), (24, 7), (9, 18), (22, 13))
def highest_element(l):
my_max = l[0]
for num in l:
if my_max < num:
my_max = num
return my_max
print highest_element (my_nested_tuple)
This is as far as I gotten. The program keeps printing out (24,7), but I want it to print out the highest element only (which is 24).
Any help or hints will be much appreciated. Thanks!
EDIT: Keep in mind that I'm in the data structures lesson in intro computer science and haven't gone any further than that.