Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions basic_examples/python_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#is the idoimatic way to access the __xxx__method
print 'I know of ', len(jvm_langs), 'langs that can run on the JVM'

print 'Oops I forgot Clojure'
print 'Oops I forgot Clojure, so lets append it to our list.'
jvm_langs.append('Clojure')

#Let's iterate across the list
Expand All @@ -19,9 +19,19 @@

#Can we get the 3rd element of the list ?
print "The 3rd JVM language is ", jvm_langs[2]
print "The first 3 JVM languages are ", jvm_langs[:3]
print "The first 3 JVM languages are ", jvm_langs[:3]#if the first index is blank it automatticaly takes 0
print "The 2nd to 4th JVM languages are ", jvm_langs[1:4]

#Can we get the value with skipping one character
print "The list after skipping 1 value looks like ",jvm_langs[::2]

#Now lets reverse the list
#First way
jvm_langs.reverse()

#Second way
print "The list after reversing its value looks like ",jvm_langs[::-1]

print "let's sort these languages"
jvm_langs.sort()
print jvm_langs
Expand Down