Skip to content

Commit

Permalink
Merge pull request #529 from ApoorvaSunkad/master
Browse files Browse the repository at this point in the history
I have added How to reverse a list in python
  • Loading branch information
MukulCode authored Oct 29, 2022
2 parents 0c044a2 + d726b05 commit d17ce9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Python for Beginners/first.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,19 @@
print(Max)



#Reversing a list in Python by two methods
# Method 1 - By using reverse() built-in function
# Input: list = [4,7,9,3,1]
# Output: [1,3,9,7,4]

lst = [4,7,9,3,1]
lst.reverse()
print("Using reverse() ", lst)

#Method 2 - By Insertion method
lst = [4,7,9,3,1]
l = []
for i in lst:
#reversig the list
l.insert(0,i)
print(l)
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,8 @@ Purbendu Halder (Kolkata)

Mohd Maaz (Gorakhpur)


Apoorva Sunkad(Dharwad, Karnataka)

Animesh Jain (Mandsaur)

0 comments on commit d17ce9c

Please sign in to comment.