Jun-01-2020, 04:44 PM
About the program.
I want the program to output all the possible results in a list. But I'm currently struggling removing the current quotes, commas, spaces and brackets from the output.
If the list contains 1 and A. I'm looking to get an output like the following:
11
1A
AA
A1
The current output without the AttributeError is:
('1', '1')
('1', 'A')
('A', 'A')
('A', '1')
Please find the code attached:
I've search online "AttributeError: 'list' object has no attribute 'replace'" but with my limited knowledge in python and overall programing I didn't manage to find a clear solution.
Thank you for your time.
I want the program to output all the possible results in a list. But I'm currently struggling removing the current quotes, commas, spaces and brackets from the output.
If the list contains 1 and A. I'm looking to get an output like the following:
11
1A
AA
A1
The current output without the AttributeError is:
('1', '1')
('1', 'A')
('A', 'A')
('A', '1')
Please find the code attached:
import itertools blocks = 2 List = ["1", "A"] List.replace(",", "") for result in itertools.product(List, repeat=blocks): print(str(result))Here is the error:
Error:List.replace(",", "")
AttributeError: 'list' object has no attribute 'replace'
I'm using the Python 3.8.3 in Ubuntu with Pycharm.I've search online "AttributeError: 'list' object has no attribute 'replace'" but with my limited knowledge in python and overall programing I didn't manage to find a clear solution.
Thank you for your time.