Can someone help me with trying to pass a variable through a function. I don't understand why 'a' needs to be defined. Shouldn't it pass through as the variable 'letter'? http://codepad.org/QRbus1ln
Yes, it pass as the variable letter, but it must be assigned some value first, if you prefer, the variable must be initialized. Whenever you say letter = str(letter), you aren't really saying that you want "letter", you are saying: I want "foo" where foo is what the variable passed argument is pointing to. Variables in Python are not equivalent to the value, they are references to the value. How could the interpreter know to what 'a' is pointing to, if you didn't assign anything to it?
alright, that makes sense. I was getting confused from the previous problem (the 1st chunk of ps5...which I'm writing a 'ghost' version of...) where function variables were already initiated and I didn't realize it. Thanks!
No problem, mate. I had that kind of problem when I was typing the lecture's code, before realizing it was on the handout, :)
I still haven't found where the handouts are. Were they supposed to come in the downloaded materials or are they on the class mainpage. Thought I checked both places...
In the video lecture, there is a tab named "Related Resources", the handout should be there.
Join our real-time social learning platform and learn together with your friends!