Python swears at this here.
TypeError: 'set' object does not support indexing
I can not understand where is the error.
for number in range(0,len(list)): if list[number] == summa: code
Python swears at this here.
TypeError: 'set' object does not support indexing
I can not understand where is the error.
for number in range(0,len(list)): if list[number] == summa: code
I can assume that the list in your case is set, and with it you can not do so list [number]
In any case, you are doing everything wrong.
First, don't call the list variable, so you replace the standard Python command
Second, rewrite your code like this:
for n in my_list: if n == summa: print 'ok'
list
you are set, and it does not have indexes - it's just a set of objects.
Try this:
for list_element in list: if list_element == summa: code
Source: https://ru.stackoverflow.com/questions/263433/
All Articles
list
? Python thinks it's a lot. - alexlzenumerate()
] [1] function. [1]: docs.python.org/2/library/functions.html#enumerate - foriton