p_phrase = "was it a car or a cat I saw"
p = p_phrase.split()
p.reverse()
print(p_phrase)
r_phrase = ""
for words in p:
if p_phrase != r_phrase + words[:-1]+"":
print(r_phrase)
I wrote the following code to reverse the string p_phrase but the output is "was it a car or a cat I saw". I don't understand how this output is given. The output I want to achieve is "was I tac a ro rac a ti saw". Can you help me?