You could try this if the depth of the list is not known upfront.
Input:
names=['jones', 'kevin', ['henry', 37, ['a', 0.69999]], ['michael', True]]
Function:
def recursive_upper(names):
ret_list=[]
for x in names:
if isinstance(x, list):
ret_list.append(recursive_upper(x))
elif (isinstance(x, basestring) or isinstance(x, int) or isinstance(x, float) \
or isinstance(x, long) or isinstance(x, bool) or isinstance(x, complex)):
ret_list.append(str(x).upper())
return ret_list
print recursive_func(names)
Output:
['JONES', 'KEVIN', ['HENRY', '37', ['A', '0.69999']], ['MICHAEL', 'TRUE']]
The function simply checks the type and recursively calls itself if type is a list. It continues to return the uppercase version of text when it finds a string, int, float, long, bool or a complex type. All other types are simply ignored. (You could add/delete types in the elif condition. Refer here )
Hope this helps :)