Python - Using integer to control while loop

Introduction

Python's while loop is a more general sort of looping tool.

It's not limited to stepping across sequences, but generally requires more code to do so:

Demo

x = 4 
while x > 0: # w ww. j a v a2s  .  com
   print('test!' * x) 
   x -= 1

Result

Related Topic