0
how do you change the order of characters in string?
I want to reverse letters in any given input
6 Antworten
+ 4
original_string = "donatoe"
#Easy way:
new_string = original_string[::-1]
#Hard way:
new_string = ""
i = len(new_string) - 1
while i != -1:
new_string += original_string[i]
i -= 1
+ 1
Can you provide some examples? I'm not getting what you're asking for here.
+ 1
My way
one = 'abcdefg'
two = []
for i in one:
two.append(i)
print(''.join(two[::-1]))
+ 1
Sound like you want a code for the extraterritorial challenge.
You've been given some good pointers already.
I suggest you review your lessons about iteration and have a look at these previous posts for your answer.
Best if you do this yourself, else nothing is learnt
+ 1
thanks
0
for example say I want to reverse "good boy" to "doog yob"