"Dayo Adewunmi" <contactd...@gmail.com> wrote


subsequently written to the file. How do I save this

<a href=\"http://users.example.com/~"; + userName + ">" + lastName + ", " + firstName + "</a>

to a variable, then?

aVar = '<a href=\"http://users.example.com/~' + userName + ">" + lastName + ", " + firstName + "</a>"

But IMHO its much easier to use string formatting:

aVar = '<a href="http://users.example.com/~%s>%s,%s</a>' %( userName,lastName,firstName)

Its also more efficient.

However in practice you don;t need to store it as a variable before writing it,
you can just write the string directly.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to