Weird Python Pass By Reference

lst = [(100, 1, 2), (101, 1, 3), (102, 1, 4), (103, 3, 4)]adj_lst = [[None]]*(4)for triple in lst:    if adj_lst[triple[1]][0] == None:        adj_lst[triple[1]][0] = [(triple[2],triple[0])]    else:        adj_lst[triple[1]].append((triple[2],triple[0]))
adj_lst = [None]*(n)lst = [(100, 1, 2), (101, 1, 3), (102, 1, 4), (103, 3, 4)]for triple in lst:    if adj_lst[triple[1]] == None:        adj_lst[triple[1]] = [(triple[2],triple[0])]    else:        adj_lst[triple[1]].append((triple[2],triple[0]))

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mike Sun

Mike Sun

Enigmatically simple. Aspiring photographer and technopreneur based in Singapore. www.linkedin.com/in/mike-sun