I am trying to convert a string in a float within an if statement. Now I can call it on the actual if line but not inside of it:
rates = "1"
if float(rates) == 1: #This works
print "Hi"
if rates == "1":
float(rates) += 1 #This doesn't work
Now the error is that the function (float()) could not be called from within the if statement for the second if statement. Why is this happening? Here is the error:
C:\Python27\python.exe C:/Users/Anthony/Desktop/Python/PyQt/Pratical_Programs/Stack_Overflow.py
File "C:/Users/Anthony/Desktop/Python/PyQt/Pratical_Programs/Stack_Overflow.py", line 5
float(rates) += 1 #This doesn't work
SyntaxError: can't assign to function call
Aucun commentaire:
Enregistrer un commentaire