Good day, I have a list of ICD 10 Codes example is U07.01, Z152.8154, X98.23 etc.. they are provided by WHO
I want to round off this to be U07.0, Z152.8, X98.2 in Odoo, I have tried to use the in built in round but is it giving an error. Here is my code....
code.text = round(str(patient_line.doc_disease_id.code).lower(), 1) or ' '
CodePudding user response:
use the str slicing
.
for example:
l = ['U07.01', 'Z152.8154', 'X98.23']
new_list = []
for i in l:
first_part, second_part = str(i).split('.')
second_part = second_part[:1]
new = f'{first_part}.{second_part}'
new_list.append(new)
print(new_list)
for only onecode at a time as OP wanted:
first_part, second_part = str(old_code).split('.')
second_part = second_part[:1]
new = f'{first_part}.{second_part}'
print(new)