diff --git a/libs/P_C.py b/libs/P_C.py index bccc90e..b920ae2 100644 --- a/libs/P_C.py +++ b/libs/P_C.py @@ -27,13 +27,23 @@ def P_C_M(A, B): # stand for Physics Calculation multiple Unit2 = [] for unit in B[3]: if unit in [Unit1]: - n = Unit1.index(unit) - Unit1.pop(n) + Unit1.remove(unit) else: Unit2.append(unit) if Unit1 == None: Unit1 = [] + print(Unit1, Unit2) + for unit in Unit2: + print(unit) + if unit in Unit1: + Unit1.remove(unit) + Unit2.remove(unit) + print(unit) + else: + pass + print(Unit1, Unit2) C = [Float, Int, Unit1, Unit2] + print(C) return C @@ -57,11 +67,16 @@ def P_C_D(A, B): # stand for Physics Calculation divide Unit2 = [] for unit in B[2]: if unit in [Unit1]: - n = Unit1.index(unit) - Unit1.pop(n) + Unit1.remove(unit) else: Unit2.append(unit) if Unit1 == None: Unit1 = [] + for unit in Unit2: + if unit in Unit1: + Unit1.remove(unit) + Unit2.remove(unit) + else: + pass C = [Float, Int, Unit1, Unit2] return C diff --git a/test.py b/test.py index 777f7fb..7a44472 100644 --- a/test.py +++ b/test.py @@ -14,6 +14,7 @@ print("B = " , B) C = libs.P_C.P_C_M(A, B) D = libs.P_C.P_C_D(A, B) - +E = libs.P_C.P_C_D(C, B) print("A × B = " , C) print("A ÷ B = " , D) +print("A × B ÷ B = " , E) \ No newline at end of file