I'm trying to convert a variable whose value changes however the value is usually to one decimal place e.g. 0.5. I'm trying to change this variable to 0.50. I'm using this code but when I run the program it says TypeError: Can't convert 'float' object to str implicitly
Here is my code:
while topup == 2:
credit = credit + 0.5
credit = str(credit)
credit = '%.2f' % credit
print("You now have this much credit £", credit)
vending(credit)
'%.2f' % creditTypeError: a float is requiredfor python 3 andTypeError: float argument required, not strfor python 2.