Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am getting an error as list object has no attribute 'join'

Tags:

python

I have a list:

ueid_list = [['0'],['0','1'],['0','1','2']...]

corefiles(str type): {"core0.log", "core4.log","core3.log","core7.log"}

RNTI(str type):{"0x0000","0x003f",...}

The below code has a loop that iterates over the above three by taking values one after other in the function and prints details accordingly...

My code:

 for a in (ueid_list):

  for b in (corefiles):

      for c in (rnti):

          getUeLinesFromcorefiles(b,a,c)

The above getueid function is defined as:

def getUeLinesFromcorefiles(filenames, ueid, rnti)
.
.
.
.
.

This is showing an error:

as attributeerror: 'list' object has no attribute 'join'

How can I deal with this error?

like image 620
Dee Avatar asked Dec 18 '18 12:12

Dee


People also ask

What does list object has no attribute replace mean?

The part “'list' object has no attribute 'replace'” tells us that the list object we are handling does not have the replace attribute. We will raise this error if we try to call the replace() method on a list object. replace() is a string method that replaces a specified string with another specified string.

What does object has no attribute mean?

It's simply because there is no attribute with the name you called, for that Object. This means that you got the error when the "module" does not contain the method you are calling.

What does AttributeError list object has no attribute split mean?

The Python "AttributeError: 'list' object has no attribute 'split'" occurs when we call the split() method on a list instead of a string. To solve the error, call split() on a string, e.g. by accessing the list at a specific index or by iterating over the list.


1 Answers

The main question is not relevant, but the title is the error I got.

I mixed up the syntax trying to join a list of strings. I was doing this:

list_of_str.join(' ')

when I should do this:

' '.join(list_of_str)
like image 150
ganski Avatar answered Oct 23 '22 01:10

ganski