| def compare_one(a, b): | |
| """ | |
| Create a function that takes integers, floats, or strings representing | |
| real numbers, and returns the larger variable in its given variable type. | |
| Return None if the values are equal. | |
| Note: If a real number is represented as a string, the floating point might be . or , | |
| compare_one(1, 2.5) âžž 2.5 | |
| compare_one(1, "2,3") âžž "2,3" | |
| compare_one("5,1", "6") âžž "6" | |
| compare_one("1", 1) âžž None | |
| """ | |
| temp_a, temp_b = a, b | |
| if isinstance(temp_a, str): temp_a = temp_a.replace(',','.') | |
| if isinstance(temp_b, str): temp_b = temp_b.replace(',','.') | |
| if float(temp_a) == float(temp_b): return None | |
| return a if float(temp_a) > float(temp_b) else b | |