Q:

Python Convert set to list, keep getting TypeError: 'list' object is not callable

I am trying to write a program that adds items to a list based on a random number. Part of the program is potentially rolling additional items, but all duplicate items should be rerolled. My issue is that when I try to do this using the methods I was able to find (compare list to set of list to test for dups, then save the set to the list), but I keep getting TypeError: 'list' object is not callable. The confusing thing is that when I test this with simple lists I set up, it works fine.
This is my code
from random import randint

# Dice roller function
def roll_dice(dice, sides, bonus):
    count = 0
    roll = 0
    for count in range(dice):
        roll += randint(1, sides)
    roll += bonus
    return roll

list = ['1', '2', '3', '4', '5']
print_list = ''
for x in range(0, len(list)-1):
    print_list += ' ' + list[x]
print print_list[1:]

# Minor special armor ability roller
def armor_special_ability():
    reroll = 1
    ability = []
    abil_list = ''
    while reroll > 0:
        result = int(raw_input('Roll:'))#roll_dice(1,100,0)
        if result <= 25:
            ability.append('Glamered')
        elif result <= 32:
            ability.append('Light Fortification')
        elif result <= 52:
            ability.append('Slick')
        elif result <= 72:
            ability.append('Shadow')
        elif result <= 92:
            ability.append('Silent Moves')
        elif result <= 96:
            ability.append('Spell Resistance (13)')
        elif result <= 97:
            ability.append('Improved Slick')
        elif result <= 98:
            ability.append('Improved Shadow')
        elif result <= 99:
            ability.append('Improved Silent Moves')
        elif result <= 100:
            reroll += 2
        reroll -= 1
        if len(ability) > len(set(ability)):
            reroll += (len(ability) - len(set(ability)))
            ability = list(set(ability))
    return ability

print armor_special_ability()

Can anyone help me figure out why I keep getting this error? I've spent hours searching the net with no success.

A:

The issue is in line -
list = ['1', '2', '3', '4', '5']

You are overwriting the in-built list function with your list , after this assignment , if you try to call list() it would cause error, as it would try to access the list you defined and call it.
Use a different name, do not ever use list as a name for a variable (unless you really wanted to overwrite the list in-built function) , since it overwrites inbuilt functions.

