Как изменить строку в Python
# in order to make a string reversed in python
# you have to use the slicing as following
string = "racecar"
print(string[::-1])
Tejas Naik
# in order to make a string reversed in python
# you have to use the slicing as following
string = "racecar"
print(string[::-1])
'hello world'[::-1]
'dlrow olleh'
function reverseString(str) {
return str.split("").reverse().join("");
}
reverseString("hello");
#linear
def reverse(s):
str = ""
for i in s:
str = i + str
return str
#splicing
'hello world'[::-1]
String str = "Hello";
String reverse(String str){
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.reverse();
return sb.toString();
}
string = "string"
rev = "".join([l for l in reversed(string)])