How to Use Python For Loop ?

In this article, you’ll learn how to use Python for loop (Range Collection, String, Collections)?

Using Python For Loop on range collection:

for elem in range(5): print(elem,end=" ") print() for elem in range(1, 6): print(elem,end=" ") print() for elem in range(5, -1, -1): print( 'Countdown: ' , elem)

Using Python For Loop in String:

for char in 'string': print(char, end=' ') print()

Using Python For Loop on Collections


for tup in (1, 3, 5): print(tup) for val in ['hey', 'hi', 'Whoa']: print(val) greek = { 'alpha': 1, 'beta': 2, 'gamma': 3} for key in greek: if key == 'beta': continue print(key, greek[key])


For any queries or doubts Ask Questions in 24Turorials Forum.

Share This Post

An Ambivert, music lover, enthusiast, artist, designer, coder, gamer, content writer. He is Professional Software Developer with hands-on experience in Spark, Kafka, Scala, Python, Hadoop, Hive, Sqoop, Pig, php, html,css. Know more about him at

Lost Password


Do NOT follow this link or you will be banned from the site!