cities=["London","New York", "Munich", "Belgrade"] if len(cities)>3: print "The first city is " + cities[0] print "The second city is " + cities[1] print "The third city is " + cities[2] print "The fourth city is " + cities[3] numbers = [8,9,10,11] print numbers[1] + numbers[3] animals = ["pangolin", "cassowary", "sloth", "tiger"] animals[3] = "owl" print animals suitcase=[] suitcase.append("sunglasses") list_length=len(suitcase) print "There are", list_length, "in the suitcase." print suitcase suitcase=["sunglasses", "hat", "passport", "laptop", "suit", "shoes"] first=suitcase[0:2] print first second=suitcase[2:4] print second third=suitcase[4:6] print third
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