How to find the highest digit in float number with Python

1 Answer

0 votes
n = -21.3
print(max(int(i) for i in str(n) if i not in '.-'))
          
n = 76.594
print(max(int(i) for i in str(n) if i not in '.-'))
          
n = -768.52
print(sorted(list(str(n)))[-1])

  
  
  
  
'''
run:
  
3
9
8
 
'''

 



answered Jun 9, 2020 by avibootz

Related questions

1 answer 171 views
3 answers 219 views
3 answers 271 views
1 answer 153 views
1 answer 157 views
1 answer 136 views
1 answer 147 views
...