""" FOR LOOPS """ #enumerate (this is a "generator" function) seasons = ['Spring', 'Summer', 'Fall', 'Winter'] print list(enumerate(seasons)) print list(enumerate(seasons, start=1)) for index, season in enumerate(seasons): print season + " is " + str(index) #zip list_a = [3, 9, 17, 15, 19] list_b = [2, 4, 8, 10, 30, 40, 50, 60, 70, 80, 90] for a, b in zip(list_a, list_b): #pulls values from both lists at same time; stops at shortest list; can do more than 2 lists if a >= b: print a else: print b """ WHILE LOOPS """
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question