Kód: Vybrať všetko
from xml.dom.minidom import Document
print "Welcome. This is the Crossword creator.\nYou can create a crossword and give it to other person to solve it.\n\nPress <ESC> to stop creating your crossword!!!\n"
cross_name=raw_input("Type a name of your crossword: ")
print 80*"*"
doc = Document()
root = doc.createElement("root")
doc.appendChild(root)
count_of=1
while 1:
number = doc.createElement("number")
root.appendChild(number)
number.setAttribute("id", str(count_of))
count_of=count_of+1
question = doc.createElement("question")
number.appendChild(question)
x=raw_input("Type a question: ")
question.setAttribute("id", str(x))
answer = doc.createElement("answer")
question.appendChild(answer)
x=raw_input("Type an answer: ")
answer.setAttribute("id", str(x))
print
xml=doc.toprettyxml(indent = " ", newl = "\n", encoding="utf-8")
crossword=open(cross_name, "w")
crossword.write(xml)
crossword.close()
print xmlp.s.: Alebo nejaky sposob, ako prerusit ten cyklus na poziadanie...