I'm trying to identify a few errors in this code below and write which kind of error it is and replace it with the correct code. I've found the three but I have a question on differentiating whether one is a runtime or a logic error.
def mirror(word): # 1
result == '' # 2
ord_a = ord('a') # 3
ord_z = ord('z') # 4
for c in word[:-1]: # 5
value = ord('c') - ord_a # 6
new_value = ord_z - value # 7
result += chr(new_value) # 8
return result # 9
I've successfully identified 4 lines (line 2, line 5, line 6, line 9) and made adjustments (testing various inputs work in the new function) here:
def mirror(word): # 1
result = '' # 2 ##### runtime error* or logic?
ord_a = ord('a') # 3
ord_z = ord('z') # 4
for c in word[::-1]: # 5 ##### logic error (supposed to reverse slicing)
value = ord(c) - ord_a # 6 ##### logic error (ord(c) not ord('c'))
new_value = ord_z - value # 7
result += chr(new_value) # 8
return result # 9 ###### syntax error (wrong indent)
My question is would line 2 count as a runtime error or a logic error, given that in the erroneous code it was comparing equality "==" rather than referencing an assignment with "=" .
Cheers