# Define a procedure, union, # that takes as inputs two lists. # It should modify the first input # list to be the set union of the two # lists. You may assume the first list # is a set, that is, it contains no # repeated elements. def union(a,b): for e in b: if e not in a: a.append(e) # To test, uncomment all lines # below except those beginning with >>>. a = [1,2,3] b = [2,4,6] union(a,b) print a #>>> [1,2,3,4,6] print b #>>> [2,4,6]
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question