Dee
Dee

Reputation: 341

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

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?

Upvotes: 31

Views: 65141

Answers (2)

gannonbarnett
gannonbarnett

Reputation: 1965

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)

Upvotes: 97

Abhicoding
Abhicoding

Reputation: 115

.join should be applied on strings. You are trying that on list. Basically, a in the for loop is a list.

Upvotes: 1

Related Questions