I have written reverse list code with O(n/2) complexity but I want to know how can I implement this code into list comprehension to get an idea of assignment operation in list comprehension.
word = list("overflow")
length = len(word)
for i in range(length//2):
word[i] , word[(length-1)-i] = word[(length-1)-i] , word[i]
print(word)
I did some researched related to my solution but i found := this operator and tried but didn't work.
word = list("overflow")
length = len(word)
word = [ word[i],word[(length-1)-i] := word[(length-1)-i] ,word[i] for i in range(length//2) ]
print(word)