#String string1 = 'string with single quotes' string2 = "string with double quotes" #Unicode string unicode1 = u'unicode string with single quotes' unicode2 = u"unicode string with double quotes" #List list1 = ['a', 'b', 'c', 'd'] #Tuple tuple1 = () tuple2 = (1,) tuple3 = 1,2,3,4 tuple4 = (5,6,7,8) #Array #array1 = array('1') #array2 = array('1', 2, u'hello') #array3 = array('1', 2, 3, [4,5,6,]) #Bytearray; mutable bytearray1 = bytearray(100) #Buffer astring = 'hello matey how are you?' buffer1 = buffer(astring, 0, 7) print buffer1 print len(astring) print len(buffer1) #In and not in operators a_collection = 'hello moto' #print 'h' in a_collection #print 'h' not in a_collection #print 'boo' in a_collection #for x in a_collection: # print x #for b in xrange(len(a_collection)): # print a_collection[b] alpha = 'abcd' #print alpha[-1] #print alpha[:] #print alpha[:-1] #print alpha[0:-1] #print alpha[1:-1] lambdalist = [1,2,3,4,5,6,7,8,9,10] x = filter(lambda x: x > 5, lambdalist) print x y = filter(lambda x: x%2 == 0, lambdalist) print y
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