Q:

How do i find the max value in a list that contains a list as a value? 

I have an exercise for a class in python and i have stuck in question 4:

Create list1 with 200 random integers in space [1,50] and print how many times the number is 10. 
Create list2 with 50 integers [1,2,3, ..., 50] and then with append() function join the lists together and display the size. 
Delete the data with index number from 99 to 130 and print the list size after deleting items. 
Find the maximum and minimum in the list. 

My first thought on how to find MAX was to sort the list and get the last value but because 1 item in the list is a list I get this error TypeError: '<' not supported between instances of 'list' and 'int'. 
Any ideas on what i have to do? 
My code until this question is the one below:
import numpy as np

#Question1
j= 0; 
list1 = list(range(200))  #decalre list1

for i in range(200): 
 list1[i] = np.random.randint(50)     #create a list of length 200 with values 0 to 50. 
 if list1[i] == 10: 
   j = j+1

print("Number 10 exists ",j,"times in the list.") 

#QUESTION2
list2 = list(range(1,51))  #Declare list2
list1.append(list2)  #append list2 on list1
print(len(list1)) 

#QUESTION3
for i in range(99,130):  # deletes the items with an index number from 99 to 130
   list1.pop(i)

print(len(list1))

A:

You need to flatten your list first before you can make any comparisons as you can't compare a list with an int.  In order to do this you can create a recursive function and pass your list
def flatten(l):
    return sum(([x] if not isinstance(x, list) else flatten(x) for x in l), [])

Be aware the the list in the above code is a protected name by Python and refers to a list data type.  What this function does is compare each item in the lists and checks if it is a list type.  If not it adds it to the list, if it is it calls the function again and goes to the next item.  You can now run the following:
>>> list1 = [1, 2, 3, 4, [5, 6, 7, 8]]
>>> flatten(list1)
>>> [1, 2, 3, 4, 5, 6, 7, 8]

You can now run Python's built in max() and min() functions
>>> max(flatten(list1))
>>> 8
>>> min(flatten(list1))
>>> 1

