vlady 0 Junior Poster in Training

Hello!

I try to get py output to html table tag. I have a problem to create table in a table...
Here is a pattern how it should look like (in yellow color)
file name: format_DOC.doc

here is the code I use to get a result. Pls can you help me how to make it?

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines

            import webbrowser
            firefox = webbrowser.get()

            premene=['x','y','z']
            marks=['1','2','3']
            text='xxxxxx'
            space=' '

            def skuska1():
                p=''
                for i in premene:
                    p+=i+'<td>'
                return p

            def skuska2():
                m=''
                for i in marks:
                    m+=i+'<td>'
                return m

            def skuska3():
                return text

            def writing():
                vytvor=open('test.html','w')

                for record in ['<table border="1" cellpadding="15" cellspacing="0" width="80%" height="25%">'
                '<tr>'
                    '<th colspan="2">HEADER</th>'
                        '</tr>'
                '<tr>'
                    '<td width="50%">text2:<p style="text-align:center;">',skuska3(),'</p></td>\<td>text 3</td>'
                        '</tr>'
                '<tr>'
                    '<td width="25%"colspan="2">text4:</td>'
                         '</tr>'
                '<tr>'
                    '<th>header</th><th>header</th>'
                          '</tr>'
                '<td>'
                '<table border="1" cellpadding="0" cellspacing="0"width="80%" height="25%">'
                '<tr>'
                    '<td>',skuska1(),'</td></tr><td>',skuska2(),'</td></tr>'
                         '</tr>'
                            '</table>'
                 '</td>'
                  '<tr>'
                    '<td width="50%"colspan="2">text7:</td>'
                        '</tr>'
                '<tr>'
                    '<td width="50%"colspan="2">text 8</td>'
                        '</tr>'
                            '</table>']:
                    vytvor.write("%s\n" % (record))




            def main():
                writing()
                firefox.open('test.html')

            if __name__ == '__main__':
                main()