Python going through links randomly in a list
Question: so here is my code

    
    
    import random
    import webbrowser
    
    results = []
    with open("al.txt") as inputfile:
       for line in inputfile:
             results.append(line.strip().split(','))
    
    x = (random.choice(results))
    
    webbrowser.open(x)
    

i tried to print out what's inside of the random and it's like this:

    
    
    [["youtube.com"], ["google.com"]]
    

so i think the "[" key is causing this

i also tried to use it like this in another script

    
    
    import webbrowser
    
    webbrowser.open(url)
    

it is working as expected so when i do

    
    
    webbrowser.open(x)
    

it just recognize x as ["youtube.com"] or "["youtube.com"]"

how can i solve this problem


Answer: 
         results.append(line.strip().split(','))
    

`split` returns a list, so `appending` it to `results` gives you a list of
list of strings, instead of a list of strings.

Use `extend` instead of `append`, so the list remains one dimensional.

    
    
         results.extend(line.strip().split(','))
    

