forked from anumsh/Python-Programs
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse.py
More file actions
Latest commit
24 lines (17 loc) · 365 Bytes
/
Copy pathreverse.py
File metadata and controls
24 lines (17 loc) · 365 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# reverse the string
# 1st method using slice
'''
def string_reverse(string1):
return string1[::-1]
print string_reverse('hello')
'''
# 2nd method through list
defreverse(list):
rlist= []
i=len(list) -1
printi
whilei>=0:
rlist.append(list[i])
i=i-1
returnrlist
printreverse("anum")