# A list like list01 below may contain several elements or items: list01 = ['Pride', 'Prejudice', 'Zombies'] # We can target particular items in a list: print list01[0] # The counting starts at zero, therefore the [0] notation gives us the first element. # Try altering the number to show the second and third elements here! # Note that the 'print' function is crucial if you want something to show up! # Code here! # A for loop is a very handy and powerful way to repeat a set of procedures # Here we use 'item' as the name for individual elements # Because the print functions below are within the for loop, the indentation is crucial #Remove the '#' in lines 21-23 to see what happens #for item in list01: # print item # print list01.index(item) # Now you see the results. Is it what you expected? If not, revisit the codes and make sure you understand HOW it works. # This is important to understand how the for loop works, before you move on to the task of the day.
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