I have written code that should do as the title says but im getting "TypeError: can only join an iterable" on line 12, in reverse_words d.append(''.join(c))
here is my following code-
def reverse_words(text):
#makes 'apple TEST' into ['apple', 'TEST']
a = text.split(' ')
d = []
for i in a:
#takes 'apple' and turns it into ['a','p','p','l','e']
b = i.split()
#takes ['a','p','p','l','e'] and turns it into ['e','l','p','p','a']
c = b.reverse()
#takes ['e','l','p','p','a'] and turns it into 'elppa'
#appends 'elppa' onto d
d.append(''.join(c))
#whole thing repeats for 'TEST' as well
#joins d together by a space and should print out 'elppa TSET'
print(' '.join(d))
reverse_words('apple TEST')
I know it has to do something that I messed up with c but I cannot identify it.
trying to reverse words while maintaining order but i got a type error