is there a better way than replace to write this function?
-- One --

You can use a dictionary to hold your translation data:

mydict = {'1':'triangle', '2':'square', '3':'rectangle',
          '4':'pentagon','5':'hexagon', '6':'octagon','7':'circle'}


Now your list of replacement lines becomes simply:

for key, value in mydict.iteritems():
    name = name.replace(key, value)


another option would be:

for key in mydict:
    name = name.replace(key, mydict[key])


To make this part complete, consider also a tuple for holding your data as indicated in @larmans answer. See also comments in the answers. I think there are interesting hints about which could be the best alternative for different cases.

-- Two --

also remember you can do

2 &lt;= total &lt;= 5


instead of

total &gt;= 2 and total &lt;= 5


-- Three --

Note you dont need parenthesis in the if expressions. Just do this:

if total == 1: