Find maximum int value from list which contain both str and int python
问题 Looking to find max from the combine list as follows: ['filename1', 1696, 'filename2', 5809,....] I have tried following: max(['filename1', 1696, 'filename2', 5809,....]) that return me TypeError: '>' not supported between instances of 'int' and 'str' . Any suggestion would help. What I want is to find the max integer value from the list above mentioned. 回答1: Use list comprehension with isinstance to extract the int and then use max . Ex: f = ['filename1', 1696, 'filename2', 5809] print(max(