Write a function called riddle that returns a two line string, with a riddle and its answer. Modify makeHomePage to insert the riddle at the end of the page rather than the tagline.

Note: This simply involves changing the tagline method on page 368 to be about riddles instead.

```
import urllib
import random

def makeHomePage(name,interests):
file=open(getMediaPath("homepage.html"),"wt")
file.write( doctype ())
file.write(title(name+"'s Home Page"))
text = "

Welcome to "+name+"'s Home Page

"
text += "

Hi! I am "+name+". This is my home page!"
text += " I am interested in "+interests+"

"
text += "

Random riddle of the day: "+riddle()+"

"
file.write(body(text))
file.close()
def riddle():
riddles = []
riddles += ["What can you catch, but not hold?\nA cold."]
riddles += ["What belongs to you but others use it more?\nYour name."]
riddles += ["What kind of stones are never found in the ocean?\nDry ones."]
riddles += ["What do elves do after school?\nGnomework."]
riddles += ["Why did the chicken cross the road?\nTo get to the other side."]
return random.choice(riddles)
```

Computer Science & Information Technology

You might also like to view...

In the accompanying figure, item 3 points to the ____________________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

If a variable is declared as static inside a function, what parts of the program can see the variable?

A. Any function called after the static variable was declared. B. Only the function in which it was declared. C. The entire program. D. Other functions declared as static.

Computer Science & Information Technology