How to change document status to amend using python

I want to edit the fields of doctype based on a web form but the doctype is submittable so i need to cancel the doctype and then amend the doctype and should edit the doctype and then again submit the doctype
I need to do this in python so how can i do it?

@Vinay1 you can copy the doctype and add the amended_from field.
however, you can edit your doctype after submitting so you don’t need to recreate it every time you edit it . just check the “allow on submit” on every field you allowing to be edited after submit .