Skip to content Skip to sidebar Skip to footer

Integer From Tuple, Divided, Yields Integer Instead Of Float?

In the code below, abc = (1,2,3) a = abc[0] b = abc[1] c = abc[2] print('%d, %d, %d' %(a,b,c)) # gives 1,2,3 as expected a /= 3 b /= 3 c /= 3 print('%d, %d, %d' %(a,b,c)) # giv

Solution 1:

Your print statements say to display the values as integers (%d); try using %f instead.

Solution 2:

You are using %d so the output is printed as ints/decimal just use print:

print(a,b,c)

Solution 3:

Use %f inside print statement

print('%f, %f, %f', %(a,b,c))

Post a Comment for "Integer From Tuple, Divided, Yields Integer Instead Of Float?"