Error:
Unnecessary semicolon
Description
Raised by Pylint, when an statement ends with semicolon. semicolon is not required in python to end statement. This error is not fatal but considered a bad
practice.
Example(s)
Given sample of code describe basic divide function, it takes
two arguments a and b. We have simple divided first argument with second and
returned result. We have putted semicolon to end simple division syntax, which is a C or perl style to end statement. Although their existence does not create problem and will execute smoothly.
"""
function to take two arguments to divide first by second
"""
try:
result = a/b;
except ZeroDivisionError:
result = 0
return result
Solution(s)
Semicolons are not needed in Python unless using multiple statements in single line, This idea is too considered poor practice. This style is used in old languages like c or perl, where semicolons are always required after each statement.
Remove Semicolon
Remove semicolon from then end of line, in-case of multiple statements Use more specific exceptions
like ZeroDivisionError, TypeError.
def divide(a, b):"""
function to take two arguments to divide first by second
"""
try:
result = a/b
except ZeroDivisionError:
result = 0
return result