Skip to content

Commit fdaab72

Browse files
authored
Merge pull request kal179#12 from GeethOnion/master
For Loop Example
2 parents b0363d7 + 6d393ab commit fdaab72

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ForLoopExample.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
n = int(input())
2+
s = '#'
3+
for i in range( 1 , n+1):
4+
print (' ' *(n-i) + s*i)

simple_scripts/ListExample.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
my_list = ['p','y','t','h','o','n']
2+
# Output: p
3+
print(my_list[0])
4+
5+
# Output: t
6+
print(my_list[2])
7+
8+
# Output: o
9+
print(my_list[4])
10+
11+
# Error! Only integer can be used for indexing
12+
# my_list[4.0]
13+
14+
# Nested List
15+
n_list = ["Happy", [2,0,1,5]]
16+
17+
# Nested indexing
18+
19+
# Output: a
20+
print(n_list[0][1])
21+
22+
# Output: 5
23+
print(n_list[1][3])

0 commit comments

Comments
 (0)