+ 1
Why does this not reverse the text that is inputted: text = input() rev_text = ' '.join(text.split()[::-1]) print(rev_text)
7 ответов
+ 1
text.split() splits at whitespace. it should reverse the order words appear but not the letters in the words.
not sure this will work, but you can try
rev_text = "".join(c for c in text[-1:0:-1])
something along those lines should work, since you can slice strings.
+ 1
As Luke said split() splits at whitespaces.
For example:
s = "abc def"
print(s.split())
The result will be:
['abc', 'def']
You can reverse strings easily:
rev_str = str[::-1]
0
ok ill try that out thx
0
both of them didnt work
0
luke you were pretty close actually
0
you got it working but no output
0
text = input()
print = rev_text = "input".join(c for c in text[-1:0:-1])