Last active
December 15, 2015 15:29
-
-
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 (…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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