CGSC 1005 Lecture Notes - Lecture 15: Polskie Radio Program I
Document Summary
This program takes the genre out of the list and just prints artists. Len is a built in function but we can replicate it using a counter and traversing a string to count the elements in a string. Counter = counter + 1 def function_name( ): Our_len(s) is replaced by whatever is in return. *return sends back the result and replaces it with the call for the function. Print will print elements even when included in a function. Inside the function: parameters act like variables but they are just placeholders until they are overwritten by a variable in the code. When calling the function, we provide arguments inside the call to assign parameters. The parameters are each assigned to a variable in the code ([str1] was assigned to [s] above) The function call must: have the same number of arguments as the definition, the same order as the parameter list, and the arguments must be the correct type of data.