ab = ab.replace(" ", "") AttributeError: 'list' object has no attribute 'replace'
Jump to turn (6)
- 1ab = ab.replace(" ", "") AttributeError: 'list' object has no attribute 'replace
- 2python code that shows all the subfolders and subfodlers of those subfolders of
- 3cmd command to get all the folders and subfolders
- 4python argparse how to make a .py that i can do file.py text, and it will print
- 5python argparse make file.py -file filename, to read whats inside the file
- 6windows env how to add all folders inside a folder to a env path
- User
ab = ab.replace(" ", "") AttributeError: 'list' object has no attribute 'replace'
- Assistant
This error occurs because the variable ab is a list, and the replace() string method can only be used on strings.
To fix this error, you can convert the list to a string before applying the replace() method. For example:
ab_string = "".join(ab) ab_string = ab_string.replace(" ", "")
- User
python code that shows all the subfolders and subfodlers of those subfolders of this directory
- Assistant