Open the context
Choose the project folder and name the files or behavior involved.
Format an integer in a selected base from 2 through 36 without changing its value. Check zero, a negative value and both base limits, rejecting booleans, fractional values and unsupported bases.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def format_radix(value, base):
if type(value) is not int or type(base) is not int or not 2 <= base <= 36:
raise ValueError("radix.input")
if value == 0:
return "0"
sign, value = ("-" if value < 0 else ""), abs(value)
digits = "0123456789abcdefghijklmnopqrstuvwxyz"
result = ""
while value:
value, remainder = divmod(value, base)
result = digits[remainder] + result
return sign + resultThe example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.