Sep-26-2017, 11:25 PM
please give a runnable sample of your code with the full error text or a clear description of the problem
IM RUN THIS CODE
Input an integer to add to the total or 'Q' to quit: 5
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-2-7df26b21c5bc> in <module>()
19 return report
20
---> 21 adding_report("A")
22
<ipython-input-2-7df26b21c5bc> in adding_report(report)
4 while True:
5 integer = input("Input an integer to add to the total or 'Q' to quit: ")
----> 6 total = total + integer
7 items = (integer/n)
8 if integer.isdigit():
UnboundLocalError: local variable 'total' referenced before assignment
WHAT AM I DOING WRONG?
IM RUN THIS CODE
total = 0 def adding_report(report = "T"): while True: integer = input("Input an integer to add to the total or 'Q' to quit: ") total = total + integer items = (integer/n) if integer.isdigit(): if report == "A": print("Items"/n/n, Integer) break elif report == "T": print(total) break elif integer.startswith().lower("Q"): break else: print("Input is invalid") return report adding_report("A")AND THEN I GET THIS ERROR
Input an integer to add to the total or 'Q' to quit: 5
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-2-7df26b21c5bc> in <module>()
19 return report
20
---> 21 adding_report("A")
22
<ipython-input-2-7df26b21c5bc> in adding_report(report)
4 while True:
5 integer = input("Input an integer to add to the total or 'Q' to quit: ")
----> 6 total = total + integer
7 items = (integer/n)
8 if integer.isdigit():
UnboundLocalError: local variable 'total' referenced before assignment
WHAT AM I DOING WRONG?