Skip to content

Commit 0da5c15

Browse files
committed
added indexing operator in Python
1 parent e2d1f59 commit 0da5c15

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

indexing/index.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Indexing operator[] = gives access to a sequence's element ( string,tuples,lists )
2+
3+
name = 'aakarsh MJ' #String created
4+
5+
print(name)
6+
if( name[0].islower() ):
7+
name = name.capitalize() #capitalizes the first letter of the word and lowercases the remaining letters
8+
9+
print(name)
10+
11+
first_name = name[:7].upper() #capitalizes the entire word
12+
print(first_name)
13+
last_name = name[8:].lower() #lowercases the entire word
14+
print(last_name)
15+
16+
new_name = "aakarsh mj!"
17+
last_char = new_name[-1]
18+
print(last_char)

0 commit comments

Comments
 (0)