I have a simple code as below:
for link in links:
products[link] = get_products(link)
I am expecting links
to be a set of strings. However, sometimes it is a single link and Python seems to break it down to individual characters in the string, which is not what I want. How can I make it treat links as a set of strings even if it is a single string?
Update: Links comes from:
def read_from_file(name):
with open(name, 'r') as file:
links = file.read()
links_set = links.split('\n')
return links_set
And the file contains one link per line.