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


i trying write program adds items list based on random number. part of program potentially rolling additional items, duplicate items should rerolled. issue when try using methods able find (compare list set of list test dups, save set list), keep getting typeerror: 'list' object not callable. confusing thing when test simple lists set up, works fine.

this code

from random import randint  # dice roller function def roll_dice(dice, sides, bonus):     count = 0     roll = 0     count in range(dice):         roll += randint(1, sides)     roll += bonus     return roll  list = ['1', '2', '3', '4', '5'] print_list = '' 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 me figure out why keep getting error? i've spent hours searching net no success.

the issue in line -

list = ['1', '2', '3', '4', '5'] 

you overwriting in-built list function list , after assignment , if try call list() cause error, try access list defined , call it.

use different name, not ever use list name variable (unless wanted overwrite list in-built function) , since overwrites inbuilt functions.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -