Question #379   Submitted by Answiki on 01/11/2021 at 04:49:01 PM UTC

What is the syntax of a for-loop in a given range in Python?

Answer   Submitted by Answiki on 01/11/2021 at 04:50:57 PM UTC

In Python, the syntax for writing a for-loop in a given range is simply:

>>> for i in range(-2, 3):
>>> 	print(i)
-2
-1
0
1
2

4 events in history
Question by Answiki 01/11/2021 at 04:51:46 PM
How to write a for loop between two integers in Python?
Question by Answiki 01/11/2021 at 04:51:17 PM
How to write a for loop in a given range in Python?
Answer by Answiki on 01/11/2021 at 04:50:57 PM

In Python, the syntax for writing a for-loop in a given range is simply:

>>> for i in range(-2, 3):
>>> 	print(i)
-2
-1
0
1
2

Question by Answiki 01/11/2021 at 04:49:01 PM
What is the syntax of a for-loop in a given range in Python?
# ID Query URL Count

Icons proudly provided by Friconix.