May-17-2017, 01:59 PM
Hello there,
I'm recently learning python using python 3.6
I'm confused why the str.join seems not to work properly in my code
there are many examples I've read and I can't find the example using input()
I'm recently learning python using python 3.6
I'm confused why the str.join seems not to work properly in my code
there are many examples I've read and I can't find the example using input()
def rev(): my_input=input("Please input what you want to reverse: ") my_output=my_input.split() for word in my_output: my_output=" ".join(my_output[::-1]) print(my_output) rev()If the input is "Python forum" the output should be "nohtyP murof". However it would yield "n o h t y P m u r o f", and if I remove the space in the join, it would yield "nohtyPmurof". Help me, I'm stuck on this. Thank you. PS: if you would, please don't use a complex example like doing this whole task in one line, I really am a beginner.