What am I doing wrong here?
money = 2.01
str_money = str(money)
last_digit = str_money[-1]
if last_digit == "0":
is_zero = True
print(is_zero)
This is the error code I get:
Traceback (most recent call last):
File "C:\Users\Robin Groot\PycharmProjects\huiswerk\TestLes2.py", line 8, in <module>
print(is_zero)
NameError: name 'is_zero' is not defined
Process finished with exit code 1
EDIT: I found the problem, At the moment the if statement is not true it breaks at print because there is no value for is_zero you can solve this by adding an else statement or putting the print into the if statement.