Why doesn't list.reverse return a list?
python, string
Solution
`list.reverse` is an inplace operation, so it will change the list and return `None`. You should be using `reversed` function, like this
"".join(reversed(rst))
I would personally recommend using slicing notation like this
rst[::-1]
For example,
rst = "cabbage"
print "".join(reversed(rst)) # egabbac
print rst[::-1] # egabbac
Problem
Here I am try to reverse the string using below logic, ``` st = "This is Ok" rst = list(st) rst.reverse() ''.join(s for s in rst) ``` It is working fine, But when I try to following below logic i am getting an error, ``` st = "This is Ok" ''.join(s for s in list(st).reverse()) ``` Here is an error, ``` ----> 1 ''.join(s for s in list(st).reverse()) TypeError: 'NoneType' object is not iterable ``` Please any one explain the above process.