0
What happens when I insert 0 in the following code? Especially range becomes range (2,1)
6 Answers
+ 3
Baran Aldemir fac will remain the same, so the output will be the initial value fac had, which is 1. The for loop breaks immediatly, but the while loop will not break.
+ 2
Baran Aldemir it doesn't assign anything, because there are no values in that range
+ 2
Replace "number" with 0 and try this:
print(list(range(2,1))
result is []
So your "for" loop can be written as "for i in []": it is never entered; it is skipped.
"fac" variable, as Aymane Boukrouh [Unavailable] pointed out, will not be changed and its value will remain equal to 1
+ 1
Nothing, it will just consider it as an empty list
+ 1
What does it assign to i then? 0? 1? None?
0
What happens then? Returns the initial fac and breaks the for loop?