Skip to content

Instantly share code, notes, and snippets.

@nharrell04
Last active December 15, 2015 15:29
Show Gist options
  • Save nharrell04/5282354 to your computer and use it in GitHub Desktop.
Save nharrell04/5282354 to your computer and use it in GitHub Desktop.
The prompt: 2. Modifying each element in a list in a function This exercise shows how to modify each element in a list. It is useful to do so in a function as you can easily put in a list of any length and get the same functionality. As you can see, len(n) is the length of the list. Create a function called myFun that takes a single argument x (…
n = [3,5,7]
def myFun(x):
z = []
for i in x:
z.append(i*2)
print z
myFun(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment