I'm using data from a CSV file in my Python program, and I'm facing a problem when trying to run each separate data piece in my program.
If I have a variable like this, which is simply a list of items from each cell in my CSV column:
name = [(x) for x in column_1]
#[Sarah, Thomas, Howard, Lisa]
I want to use individual elements further from this. If I want to replace a link with each name from my column_1 data, and generate a big list of new links, how would I go about doing this?
print(new_link)
www.Sarah.com
www.Thomas.com
www.Lisa.com
My code looks like this so far, but I'm having trouble replacing the list as simply individual element strings from the list:
link = 'www.hello.com'
new_link = link.replace('hello', [(x) for x in name])
Where am I going wrong? Would appreciate any help - thanks!
[f'www.{x}.com' for x in name]