Strings: making HTML tags

From Computer Science Wiki
Revision as of 11:48, 15 March 2016 by Bmackenty (talk | contribs)

This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.

The problem

This problem is designed to test your understanding of strings, specifically your knowledge and understanding of combining (concatenating) strings.

The web is built with HTML strings like "Yay" which draws Yay as italic text. In this example, the "i" tag makes and which surround the word "Yay". Given tag and word strings, create the HTML string with tags around the word, e.g. "Yay".
make_tags('i', 'Yay') → 'Yay'
make_tags('i', 'Hello') → 'Hello'
make_tags('cite', 'Yay') → 'Yay'

some code to get you started

#
# this is a simple function which takes two parameters, tag and word. the function returns a HTML opening and closing pair of tag, with word in the middle. See above for examples our output.  
#

def make_tags(tag, word):

    return


one possible solution

take this farther

References