[FIXED] reverse list in the python

Issue

I'm trying to reverse a integer and using the below code but the resultant list value in None. How much can we put in a list? The code:

int_a= [1,2,3,4,5,6]
rev_word = int_a.split()
rev_number = rev_number.reverse()
rev_number= "".join(rev)

it return the TypeError. Why?


Solution

Here is the short and optimal way to reverse a list in python:

int_a= [1,2,3,4,5,6]
int_a = int_a[::-1] 


Answered By - Muhammad Abbas
Answer Checked By - Marie Seifert (Python.Easybugfix Admin)

Related Posts

Post a Comment