File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ #finding length of string built in function
2
+ #len() function
3
+ x = "kkkkkk"
4
+ print (len (x ))
Original file line number Diff line number Diff line change
1
+ strng = input ("Enter a string: " )
2
+ length = len (strng )
3
+
4
+ # method 1
5
+ for i in range (length ):
6
+ print (strng [length - i - 1 ], end = "" )
7
+
8
+ # method 2
9
+ for i in range (length - 1 , - 1 , - 1 ):
10
+ print (strng [i ], end = "" )
11
+
12
+ # method 3
13
+ print (strng [::- 1 ])
14
+
15
+ # method 4
16
+ print ("" .join (reversed (strng )))
17
+
18
+ # method 5
19
+ print ("" .join (strng [length - i - 1 ] for i in range (length )))
20
+
21
+ # method 6
22
+ print ("" .join (strng [i ] for i in range (length - 1 , - 1 , - 1 )))
23
+
24
+ # method 7
25
+ print ("" .join (strng [i ] for i in reversed (range (length ))))
26
+
27
+ # method 8
28
+ print ("" .join (strng [i ] for i in range (length ))[::- 1 ])
29
+
30
+
31
+
32
+
You can’t perform that action at this time.
0 commit comments