I started learning python just now, through the book "Think like a computer scientist" and I have got stuck in some language syntax.
def amt():
amount = input("Enter your amount: ")
amount = int(amount)
if amount >= 20:
twe = amount / 20
amount = amount - twe * 20
print("You need to pay %d twenty dollar bills" %(twe))
if amount >= 10:
ten = amount / 10
amount = amount - ten * 10
print("You need to pay %d ten dollar bills" %(ten))
if amount >= 5:
five = amount / 5
amount = amount - five * 5
print("You need to pay %d five dollar bills" %(five))
if amount >= 1:
one = amount / 1
amount = amount - one * 1
print("You need to pay %d one dollar bills" %(one))
amt()
when I run this with some input say 7 I get an error message like this:
Traceback (most recent call last):
File "dollars.py", line 21, in <module>
amt()
File "dollars.py", line 7, in amt
print("You need to pay %d twenty dollar bills" %(twe))
UnboundLocalError: local variable 'twe' referenced before assignment
Why isn't the if statement working properly? Even though input value is less than 20 its still entering into the first if statement

7as input this code works fine.%instead of//. Please see my answer.