Why am I getting this error? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Why am I getting this error? (/thread-5300.html) |
Why am I getting this error? - beemanjo - Sep-27-2017 please give a runnable sample of your code with the full error text or a clear description of the problem WHY AM I GETTING THIS ERROR def adding_report(report = "T"): while True: integer = input("Input an integer to add to the total or 'Q' to quit: ") total = 0 total = total + integer if integer.isdigit(): if report == "A": str(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")File "<ipython-input-1-93d20aaf6069>", line 10 str(print("Items"\n\n, integer)) ^ SyntaxError: unexpected character after line continuation character RE: Why am I getting this error? - buran - Sep-27-2017 Simple answer - because you have \n\n after the closing " of string Items on line 9.\ at the end of the line is used to indicates that the logical line is continued on the following physical line (after whitespace). In your case your code continues on the same line...line#9 should be str(print("Items\n\n", integer)) RE: Why am I getting this error? - wavic - Sep-27-2017 Well, print() function returns None so I can't guess why you are passing it as an argument to str()... RE: Why am I getting this error? - buran - Sep-27-2017 oh, didn't notice this... Of course wavic is right print("Items\n\n", integer) RE: Why am I getting this error? - nilamo - Sep-27-2017 I'm locking this thread as a duplicate. Please don't post the same thing multiple times. |