Skip to content

Commit 4b63e2b

Browse files
committed
made a few changes to the python_lists.py file
1 parent 16edb2d commit 4b63e2b

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

README

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ I am listing the order in which you may want to read these examples. The order b
88
- python_numbers.py
99
- python_booleans.py
1010
- python_conversions.py
11-
- using_modules.py
11+
- using_modules.py
12+
- string_interpolation.py
13+
- python_lists.py
14+

basic_examples/python_lists.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
#!/usr/bin/python
2-
# Filename : python_collections.py
2+
# Filename : python_lists.py
33

44
jvm_langs = ['Java', 'Jython', 'Groovy', 'Scala', 'Jruby']
5-
print 'I know of ', jvm_langs.__len__, 'langs that can run on the JVM'
5+
6+
#How many JVM langs do you know ?
7+
print 'I know of ', jvm_langs.__len__(), 'langs that can run on the JVM'
8+
9+
#It's not a good idea to directly us __xxx__ methods
10+
#A better way is. Remember there is usually a top level function which
11+
#is the idoimatic way to access the __xxx__method
12+
print 'I know of ', len(jvm_langs), 'langs that can run on the JVM'
613

714
print 'Oops I forgot Clojure'
815
jvm_langs.append('Clojure')
16+
17+
#Let's iterate across the list
918
for lang in jvm_langs:
1019
print lang
20+
21+
#Can we get the 3rd element of the list ?
22+
print "The 3rd JVM language is ", jvm_langs[2]
23+
print "The first 3 JVM languages are ", jvm_langs[:3]
24+
print "The 2nd to 4th JVM languages are ", jvm_langs[1:4]
1125

1226
print "let's sort these languages"
1327
jvm_langs.sort()

0 commit comments

Comments
 (0)