Difference between Reverse() and Reversed() built-in functions in Python.

Vinita
1 min readAug 20, 2020

While both reverse() and reversed() are built-in functions and they are used to reverse a list but we need to understand two differences w.r.t. this:

  1. The space of their use.
  2. The reason of their use.

So, here we go:

  1. reverse()

Let us suppose, that the name of the list we are using here is- name.

So here, the following command will simply reverse the list and paste it back in the place of the original list.

name.reverse()

2. reversed()

Now here, we need to understand that, this command is used as an ITERATOR. That means, if I need to run the For Loop, from the reverse side of the existing list i.e. name:

I can use this reversed() in the following manner:

x for x in reversed(name)

Here, we are not reversing the list Actually, but temporarily the for loop will function on the reversed form of the original list i.e. name.

Thanks :)

--

--

No responses yet