Formatting Python output

The following is a cgi page which has been written in Python3.4.  It is the action page of a html form. The pages does process the form input and does give an output which is correct content wise. However it is not formatted correctly and looks like this :

Helloo ('james', 'KANE', '', '2014-09-09')!

I would like an output something like this :

Hello James Kane

If someone could take a look at the code below and fix the code and/or point me to some on line document it would be great !! Thanks for reading this.  jim

import cgi
def htmlTop():
             <DOCTYPE html>
             <html lang="en">
                  <meta charset="utf-8"/>
                  <title> My Server-side template</title>

def htmlTail():
def getData():
      formData = cgi.FieldStorage()
      firstname = formData.getvalue('firstname')
      secondname = formData.getvalue('secondname')
      youremail = formData.getvalue('youremail')
      birthday = formData.getvalue('birthday')
      return firstname,secondname,youremail,birthday
#main program

if __name__== "__main__":
            firstName = getData()
            print("Helloo {0}!".format(firstName))          

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
Try replacing line 31 with:
print("Hello {0[0]} {0[1]}<br/>\n{0[2]}<br/>\n{0[3]}<br/>\n".format(firstName))

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Robert SchuttSoftware EngineerCommented:
Couple of extra remarks:
- I added code tags to the code in your question to be able to refer to the line number
- there seems to be an error in your code: <DOCTYPE html> shouldn't that be <!DOCTYPE html>
- I used <br/> instead of <br> because you have a meta tag using it as well, but probably both are unnecessary.
jameskaneAuthor Commented:
Robert, very many thanks !!

Works perfectly.

Would you have a pointer to an online resource which deals with formatting topic ?

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

jameskaneAuthor Commented:
Just Great !!!!
Robert SchuttSoftware EngineerCommented:
Well the documentation is kind of complex but there are ample examples:
jameskaneAuthor Commented:
thanks very much again !
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.