0
def strint2():
total=0
t=0
for i in "1.23,2.4,3.123":
    if(i.isdigit()):
        x=int(i)
    if(i!='.' and i!=','):
        x=x/(10**t)
        t=t+1
        total=total+x
    if(i==","):
        t=0         
print(total)

The result is 6.752999999999999 instead of 6.753 (the sum of numbers in the string) I want to make this program with nameless String { without doing this s=""} please help

rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38
Adarsh Kumar
  • 73
  • 1
  • 6

0 Answers0