+ 12
How to reverse this string ? Like. " Risha " to "aRish" only last letter reverse not whole string.
Programming??
46 Answers
+ 15
in python
name=input("Enter your name ")
print(name[-1]+name[:len(name)-1])
+ 6
System.out.println(String.valueOf(Risha".charAt("Risha".length()-1))+
"Risha".replaceAll("Risha".charAt("Risha".length()-1),""));
+ 5
Thanks sir very very thanks
+ 5
This is how you can do it in Java:
String letter = input.next();
int len = letter. length() ;
/*Substring method where letters falling between the 2 indexes of a word is selected and taken out ,here,letter between length(last index) and len-1 ,i.e.second last index*/
String first = letter.substring(len-1,len);
//from 0 to the rest of the word except last one
String word = letter.substring(0,len-1);
//connecting the letter to the word at the end .
String subReslt = first.concat(word);
System.out.print(subReslt);
+ 4
yeah, extract last letter and put it at the beginning, but in C you need to rotate (not reverse) the rest of the string yourself. Here: https://code.sololearn.com/cdV3q1iXIXHl
+ 4
btw people, when someone asks something so simple, they're probably stumped and don't know where to start, and you're just impending their progress if you don't help, imo.
At a course once, the trainer asked us to debounce a button on a microcontroller. I think we wasted more than two hours, and would have probably wasted two days, until he showed us, and in less than five minutes I was improving on his solution in ways he didn't think of. Later I rewrote the function to work for more than one button with less code and memory.
Another time he told us to set a timer. We wasted more than two days, he kept telling us to 'read the datasheet'. We didn't know _how_ to read the datasheet, until he showed us, by the end of the day we were setting timers and PWM's like champs. We just needed a little help to get started.
I like to think most people don't cheat themselves and copy without understanding.
+ 4
public class Program
{
public static void main(String[] args) {
String name="Risha";
System.out.print(name.replace("Rish", " ")+name.replace("a", " "));
}
}
+ 4
And this is Java:
public static void main(String[] args) {
String name = "Kavoos";
int length = name.length();
char place0 = name.charAt(length -1);
String newName = place0 + name.substring(0,length - 1) ;
System.out.println(newName);
}
Easily replace "Kavoos" with anything you want.
+ 3
idk Mirielle🐶 , I am like deaf and blind when I have to do for the first time something that is not from my area of expertize, I don't see simple solutions, while a few examples can send me skyrocketing. Maybe that's just me, I have fixed, narrow ways that I hardly see out of, until somebody shows me, that is.
+ 3
Very very thanks sir
+ 3
In python..
s=str(input())
print(s[-1]+s[:-1])
+ 3
Great
+ 3
Thank you noor sir
+ 3
You're welcome BTW. :))
+ 3
At least try before you ask please.
name = "Risha"
new = name[-1]+name[1:]
+ 3
Thanks whyfry
+ 3
Thanks IITN
+ 2
C or cpp
+ 2
Ohh
+ 2
are didi ye to btaiye ki kis language se karna hai. ,😂😂😂😂😂