''builtin_function_or_method' object has no attribute 'replace'
Trying to reformat the elements of a list, that was obtained from the Web.
Need to remove 'Tags' from each element and separate the tags with a pipe (|). Using a for loop to use replace() and strip() function but getting this error:
AttributeError: 'builtin_function_or_method' object has no attribute 'replace'
tags: [<function str.strip(chars=None, /)>,
'Tags: abilities choices',
'Tags: inspirational life live miracle miracles',
'Tags: aliteracy books classic humor',
'Tags: be-yourself inspirational',
'Tags: adulthood success value',
'Tags: life love',
'Tags: edison failure inspirational paraphrased',
'Tags: misattributed-eleanor-roosevelt',
'Tags: humor obvious simile',
'Tags: friends heartbreak inspirational life love sisters',
'Tags: courage friends',
'Tags: simplicity understand',
'Tags: love',
'Tags: fantasy',
'Tags: life navigation']
for item in range(0, len(tags)):
tags[item] = tags[item].replace('Tags:', '')
tags[item] = tags[item].strip()
tags[item] = tags[item].replace(' ', '|')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
