loop_condition = True
while loop_condition:
print("Loop Condition keeps: %s" %(loop_condition))
loop_condition = False
Asked
Active
Viewed 67 times
0
-
3Did you look at the documentation at all? This is string formatting, like printf in C. When you have `string % item` or `string % tuple`, each element on the right side is substituted for any % items in the string. In this case, %s asks that it be printed as a string, so this will print "Loop Condition keeps: True" and then "Loop Condition keeps: False". – Tim Roberts Oct 27 '21 at 05:49
-
loop_condition = False while loop_condition: print("Loop Condition keeps: %s" %(loop_condition)) loop_condition = True ..... after replacing true and false .. why the output is not showing anything bro? can you please explain it? – Vin ben Oct 28 '21 at 07:46
-
Your `while` loop only runs if `loop_condition` is True. If you set `loop_condition` to False, then the loop will not run at all. – Tim Roberts Oct 28 '21 at 16:22
1 Answers
0
The %s
will be replaced by the variable loop_condition
within the string. The "s" means that the variable is formated as a string

HydeNor
- 78
- 4