I am new to python. I am getting this error when I run the below code
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-17-cdb5a334e110> in <module>
16
17 duplicates_removed = clean_strings
---> 18 duplicates_removed = list(dict.fromkeys(duplicates_removed))
19 print(duplicates_removed)
TypeError: 'function' object is not iterable
Can someone please point me in the right direction?
code
import re
def remove_punctuation(value):
return re.sub('[!#?]', '', value)
clean_ops = [str.strip, remove_punctuation, str.title]
def clean_strings(strings, ops):
result = []
for value in strings:
for function in ops:
value = function(value)
result.append(value)
return result
clean_strings(states_1, clean_ops)
duplicates_removed = clean_strings
duplicates_removed = list(dict.fromkeys(duplicates_removed))
print(duplicates_removed)