Break outside loop & invalid syntax error for a python code

Viewed 35

I'm having a BREAK OUTSIDE LOOP & INVALID SYNTAX ERROR for a PYTHON CODE

Need help fixing the issue.

The problem is located here at line 43:

# taking input for every week
x = int(input("SalesPerson {emp} week {ii}: ".format(emp = employee , ii = i)))
# appending the sales value to the list sales record for further use
sales_record.append(x)
else:
# if no another employee exists, then break the loop
break

When I run the code, I get an error at line 43: BREAK OUTSIDE LOOP & INVALID SYNTAX ERROR

2 Answers

The keyword break is meant to exit a loop. You are not in a loop when you use the keyword break, therefore it is not valid.

See the Python Language Reference documentation for break.

Without any more details, we can't know what you are hoping to achieve with break

you have no if statement if you do have an if statement please send the full code

Related