Open carlkma opened 2 years ago
Colons that do not align with the following usages are considered misplaced:
Colons serve three (3) primary purposes in Python:
- a slice operator, e.g.,
sub_string = a_string[3:9]
- a signal for the start of indented blocks, e.g., after
for i in range(10):
- a designation for key:value pairs in a dictionary, e.g.,
a_dict = {"a_key": "a_value"}
Thus, we can conduct simple regex
checks to verify if
[]
(for strings and lists) or {}
(for dictionaries)if
, else
, while
, or for
statement
return the exact position(s) of misplaced colons (if any) and suggest a valid colon position