0

What is the input of programme to print reverse of a string without using slice operator???

String s

5th Dec 2019, 12:21 PM
Lakshmi Prasanna
5 Antworten
+ 4
You can also use a simple while loop or a nice comprehension: [Edited: added a for loop] # using while loop text = 'Hello World' i = len(text)-1 while i >= 0 : print(text[i], end='') i -= 1 # using comprehension [print(i, end='') for i in reversed(text)] # using for loop for i in reversed(range(len(text))): print(text[i], end='')
5th Dec 2019, 4:09 PM
Lothar
Lothar - avatar
+ 3
Hint - Use charAt(i) in Java in Reverse order.
5th Dec 2019, 12:34 PM
A͢J
A͢J - avatar
+ 2
print(''.join(reversed('Hello')))
5th Dec 2019, 2:14 PM
HonFu
HonFu - avatar
+ 1
For loop(index from end to start) Revesed function
5th Dec 2019, 2:16 PM
Sgk101
Sgk101 - avatar
+ 1
string = "string S" # Your string print(*reversed(string),sep='')
5th Dec 2019, 3:40 PM
abderrahim sallami
abderrahim sallami - avatar