0

code is for finding the last digit of float but it can't do its job so please help

https://code.sololearn.com/cHYJfiY0BxzL/?ref=app

20th Oct 2020, 10:27 AM
Luka Maghlaperidze
Luka Maghlaperidze - avatar
3 Answers
+ 1
Your code is almost working. The problem is if you do substraction to the last digit. Both side are equaled and the result will be zero afterwards. You have to avoid substraction at the last digit.
20th Oct 2020, 10:43 AM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 1
Input your float value as string and print str[len(str)-1]
20th Oct 2020, 10:38 AM
Hima
Hima - avatar
+ 1
f = 9.45678 print(str(f)[-1]) #prints 8
20th Oct 2020, 11:24 AM
Flash