How to find the highest digit in negative int number with Python

1 Answer

0 votes
n = -213
print(max(int(i) for i in str(n) if i not in '.-'))
          
n = -76594
print(max(int(i) for i in str(n) if i not in '.-'))
          
n = -76852
print(sorted(list(str(n)))[-1])

  
  
  
  
'''
run:
  
3
9
8
 
'''

 



answered Jun 9, 2020 by avibootz

Related questions

3 answers 228 views
3 answers 290 views
1 answer 160 views
1 answer 145 views
1 answer 156 views
1 answer 148 views
1 answer 170 views
...