5 Answers
New AnswerHi! Previously, I misunderstood your question. You can add this snippet after you calculated sum variable. I hope this is what you're asking if sum%1 ==0: print(int(sum)) else: print(sum)
Python Learner thanks bro I tried ( sum - int(sum)) == 0 https://code.sololearn.com/c5ODZ9jtz863/?ref=app
Sacar How about this code? :- foo = lambda f: f if f % 1 else int(f) # I hope that this helps. Happy coding!
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message