vesh = [dct[bots[l]][s]['m'],dct[bots[l]][s]['p']] name = ''.join(vesh[0]) price = ''.join(vesh[1]) weapon = name + price TypeError: can only join an iterable
why?
vesh = [dct[bots[l]][s]['m'],dct[bots[l]][s]['p']] name = ''.join(vesh[0]) price = ''.join(vesh[1]) weapon = name + price TypeError: can only join an iterable
why?
str.join (iterable) expects as an argument iterable - an object that supports iteration .
An item capable of returning it at one time. Examples of iterables include all sequence types (
list__iter__()or__getitem__()method. It is needed (zip(),map(), ...). When an iterable object is used, it returns an iterator to the object. This iterator is over for the set of values. When using iterables, it is usually not necessary to calliter()or deal with the iterator objects yourself. The statement for the statement is a statement. See also iterator , sequence , and generator .
in simple in Russian (c) @jfs :
''.join()takes a composite object — a collection of strings, such as a list, which you can pass in a for-loop to bypass all strings
Here is one way to determine if an object is iterable and at the same time examples of objects to be iterated:
In [1]: import collections In [2]: isinstance(['a','b'], collections.Iterable) Out[2]: True In [3]: isinstance('ab', collections.Iterable) Out[3]: True In [4]: isinstance('a', collections.Iterable) Out[4]: True In [5]: isinstance([1,2], collections.Iterable) Out[5]: True In [6]: isinstance(1, collections.Iterable) Out[6]: False # NOT iterable In [7]: isinstance((1), collections.Iterable) Out[7]: False # NOT iterable In [8]: isinstance((1,), collections.Iterable) Out[8]: True In [9]: isinstance({'a':'b'}, collections.Iterable) Out[9]: True In [10]: isinstance({}, collections.Iterable) Out[10]: True In [11]: isinstance(set([1]), collections.Iterable) Out[11]: True In [12]: isinstance(set(), collections.Iterable) Out[12]: True In [13]: isinstance(open('d:/temp/aaa.txt', 'w'), collections.Iterable) Out[13]: True ''.join takes a composite object — a collection of strings, such as a list, which you can pass in a for-loop to bypass all strings. - jfsSource: https://ru.stackoverflow.com/questions/620199/
All Articles
join(iterable)expects an object that supports iteration as an argument - the error itself is what exactly this says - MaxU(dct [bots [l]] [s] ['m'], dct [bots [l]] [s] ['p'])? Per square space[]- And