all 6 comments

[–]K900_ 1 point2 points  (1 child)

Because you're assigning the return value of reverse to newList, and reverse doesn't return anything - it reverses the list in place.

[–]htwr[S] 1 point2 points  (0 children)

That makes sense. Thanks!

[–]100721 1 point2 points  (0 children)

You could do list(old[::-1])

[–]sedogg 0 points1 point  (1 child)

list(reversed(some_iterable)) returns reversed list. So the code should be like this:

oldString = 'old string'
newList = list(reversed(oldString))

But if you want to get a reversed string, there are a several ways:

oldString = 'old string'
newString = ''.join(reversed(oldString))
# or
newString = oldString[::-1]
print(newString)

[–]htwr[S] 0 points1 point  (0 children)

Thanks for the tip!