a = 1
for x in range(5):
a += 0.1
print(a)
This is the result:
1.1
1.2000000000000002
1.3000000000000003
1.4000000000000004
1.
Assuming that your problem is only displaying the number, @Jaco 's answer does the job. However if you're concern about using that variable and potentially make comparisons or assigning to dictionary keys, I'd say you have to stick to round(). For example this wouldn't work:
a = 1
for x in range(5):
a += 0.1
print('%.1f' % a)
if a == 1.3:
break
1.1
1.2
1.3
1.4
1.5
You'd have to do:
a = 1
for x in range(5):
a += 0.1
print('%.1f' % a)
if round(a, 1) == 1.3:
break
1.1
1.2
1.3