PI. List operations

Run Settings
LanguagePython
Language Version
Run Command
# Let's define a few lists to operate with la = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] lb = ['a', 'b', 'c', 'd'] # Access to elements is possible with a well known and spread syntax print lb[0] # Slising is even more powerfull then strings has print la[1:5] print la[-3:] ## THis line also well know as way to copy entire list value-by-value print lb[:] ## Also here's some megic... Lets assign something to slice of the list lb[:2] = ['e', 'f'] print lb # + operator is simply concatenate lists print la[:2] + lb # * operator is create a new list from repetitions of given print lb[:2] * 3 # len() buil-in function which will calculate list length for you print len(la), len(lb)
Editor Settings
Theme
Key bindings
Full width
Lines