Question: I have a df that looks like this:

[![enter image description here](https://i.stack.imgur.com/PBVX9.png)](https://i.stack.imgur.com/PBVX9.png)

I want to remove the part that is equal to `ID` from `Name`, and then build three new variable which equal to the last two digit of `Name`, the 3 place in `Name', and 4th place in` Name". sth that will look like the following:

[![enter image description here](https://i.stack.imgur.com/DPIQY.png)](https://i.stack.imgur.com/DPIQY.png)

What should I do in order to achieve this goal?

```
df<-structure(list(Name = c("LABCPCM01", "TUNISCN02", "HONORCN01", 
"KUCCLCN02", "LABCPBF03", "LABCPBF04", "MFHLBCM01", "MFHLBCF01", 
"DRLLBCN01", "QDSWRCN03", "QDSWRCN04", "UTSWLHN01", "MGHCCBN02", 
"JHDPCHM01", "UNILBCF03", "UTSWLGN03", "PHCI0CN01", "PHCI0CN02"
), ID = c("LABCP", "TUNIS", "HONOR", "KUCCL", "LABCP", "LABCP", 
"MFHLB", "MFHLB", "DRLLB", "QDSWR", "QDSWR", "UTSWL", "MGHCC", 
"JHDPC", "UNILB", "UTSWL", "PHCI0", "PHCI0")), row.names = c(NA, 
-18L), class = c("tbl_df", "tbl", "data.frame"))

```

Answer: 
Use [`split`](https://docs.python.org/3/library/stdtypes.html#str.split), then reverse the string and finally [`capitalize`](https://docs.python.org/3/library/stdtypes.html#str.capitalize):

```
s = 'this is the best'

res = " ".join([si[::-1].capitalize() for si in s.split()])
print(res)

```

**Output**

```
Siht Si Eht Tseb

```
The other answers here works as well. But I think this will be a lot easier to understand.

```
s = 'this is the best'

words = s.split()  # Split into list of each word
res = ''
for word in words:
    word = word[::-1]  # Reverse the word
    word = word.capitalize() + ' '  # Capitalize and add empty space
    res += word  # Append the word to the output string

print(res)

```