Skip to content

Commit

Permalink
update labels conversion function
Browse files Browse the repository at this point in the history
  • Loading branch information
DonaldLamNL committed Sep 5, 2024
1 parent 9df1b61 commit 83019aa
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions global_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ def convert_number(label, number):

# Convert label back to number
def convert_symbol(label, symbol):
if label.startswith('n'):
return int(symbol)
elif label.startswith('a'):
lower_case = True if label.endswith('l') else False
return int(alphabet_to_num(symbol))
elif label.startswith('r'):
lower_case = True if label.endswith('l') else False
return int(roman_to_num(symbol))
try:
if label.startswith('n'):
return int(symbol)
elif label.startswith('a') and symbol.isalpha():
return int(alphabet_to_num(symbol))
elif label.startswith('r'):
return int(roman_to_num(symbol))
except:
return None


# Convert number to Roman number
def num_to_roman(num, lower_case=False):
Expand Down

0 comments on commit 83019aa

Please sign in to comment.