December 6th, 2012, 12:27 AM
a = [0, 4, 0, 3, 2]
while x > 0:
What is the value which cause the program to run forever?
I do not know the answer please help me. An explanation is GREATLY appreciated. I need a explanation for this.
December 6th, 2012, 08:12 AM
Let's see here.
x is a function argument.
We could try calling the function with one parameter.
>>> mystery('hello world')
Let's look at the function guts.
It compares x with 0. Maybe x should be a number.
And we see that if x has to be positive or the program will quit. Now we can try
OH! x needs to be a positive integer.
Greater than 0 but less than the length of the short list.
Now we can trace the program execution for values in range(1,len(a))
[/code] are essential for python code and Makefiles!