+ 6

How to replace last letter of each word in string in end in python?

For example: long road - ongl oadr

11th Jul 2020, 7:26 AM
Ситникова Варвара
Ситникова Варвара - avatar
3 Respuestas
+ 7
Ситникова Варвара , before asking here for code, you should do a try by yourself first, and put it in playground. Then link it here. Thanks! But to give you some hints: (1) split the input string to individual words / elements in a list (2) iterate through this list (each element is now a complete word) (3) now pick word without first char + first character of word and put them together to a new word (4) store result in a list or use print to output result happy coding!
11th Jul 2020, 11:35 AM
Lothar
Lothar - avatar
+ 5
Remember that strings are immutable in python
11th Jul 2020, 7:44 AM
Oma Falk
Oma Falk - avatar
+ 4
I see youre on pig latin. Try using index slicing and see what you can do. For example a = 'hello' b = 'j' + a[1:] print(b) #jello
11th Jul 2020, 7:31 AM
Slick
Slick - avatar