0
How to reverse a name in python?
To reverse a "solo learn" to "learn solo" Without using array
6 ответов
+ 6
s=input().split()
print(' '.join(s[::-1]))
+ 3
Sadra Shakouri 🇮🇷
There is no reverse attribute in str object.
+ 3
Jan Markus 🅰🅹 🅐🅝🅐🅝🅣 ,
Yea I messed up
+ 2
sarada lakshmi
Thanks
+ 2
"""
mmhh...
OP said in description: << to reverse a "solo learn" to "learn solo" Without using array >>
but split return a list (wich are python array in a sense) ^^
"""
s = " " + input()
r = ""
w = ""
for c in s[::-1]:
if c != " ":
w = c + w
continue
if r: r += " "
if w: r += w
w = ""
print(r)
+ 1
Sadra Shakouri 🇮🇷
I mess up every time I don't take the time to verify, so I know how you feel.
Good on you for acknowledging your mistake