Unreachable code
4def side_height(length, breadth):
5 value = sqrt(length**2 + breadth**2)
6 return value
7 print("The side height is", value) 8
9
10def all_primes(nums):
Description
This statement is unreachable, as the control flow will never reach upto this point. Consider removing this part of code or re-evaluating the control flow.
Bad practice
def count_pairs(users):
pairs = 0
for user in users:
if user.type == "student":
pairs += 1
return pairs
pairs /= 2 # <-- Unreachable
Preferred
def count_pairs(users):
pairs = 0
for user in users:
if user.type == "student":
pairs += 1
pairs /= 2
return pairs