+ 12

How to reverse this string ? Like. " Risha " to "aRish" only last letter reverse not whole string.

Programming??

11th Jan 2020, 4:37 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
46 Answers
+ 15
in python name=input("Enter your name ") print(name[-1]+name[:len(name)-1])
12th Jan 2020, 5:18 AM
Saroj Patel
Saroj Patel - avatar
+ 6
System.out.println(String.valueOf(Risha".charAt("Risha".length()-1))+ "Risha".replaceAll("Risha".charAt("Risha".length()-1),""));
11th Jan 2020, 2:40 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 5
Thanks sir very very thanks
11th Jan 2020, 5:25 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 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);
12th Jan 2020, 4:41 AM
ASM
ASM - avatar
+ 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
11th Jan 2020, 5:19 AM
Selin Genkur
+ 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.
11th Jan 2020, 6:10 AM
Selin Genkur
+ 4
public class Program { public static void main(String[] args) { String name="Risha"; System.out.print(name.replace("Rish", " ")+name.replace("a", " ")); } }
12th Jan 2020, 6:53 AM
manojkdm18
manojkdm18 - avatar
+ 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.
12th Jan 2020, 6:56 PM
Kavoos Salahi
Kavoos Salahi - avatar
+ 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.
11th Jan 2020, 6:59 AM
Selin Genkur
+ 3
Very very thanks sir
12th Jan 2020, 4:42 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
In python.. s=str(input()) print(s[-1]+s[:-1])
12th Jan 2020, 6:20 AM
Selvi. P
+ 3
Great
12th Jan 2020, 6:46 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
Thank you noor sir
12th Jan 2020, 6:49 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
You're welcome BTW. :))
12th Jan 2020, 7:12 PM
Kavoos Salahi
Kavoos Salahi - avatar
+ 3
At least try before you ask please. name = "Risha" new = name[-1]+name[1:]
12th Jan 2020, 7:48 PM
inxanedev!
inxanedev! - avatar
+ 3
Thanks whyfry
13th Jan 2020, 6:53 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
Thanks IITN
13th Jan 2020, 6:38 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
C or cpp
11th Jan 2020, 4:57 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Ohh
12th Jan 2020, 4:33 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
are didi ye to btaiye ki kis language se karna hai. ,😂😂😂😂😂
12th Jan 2020, 4:52 PM
kshitij Mishra
kshitij Mishra - avatar