[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python string with character exchange

On Sun, Jul 14, 2019 at 12:20:56PM -0400, Matt Zand wrote:
> Given a string, return a new string where the first and last chars have
> been exchanged.

This sounds awfully like a homework question.
What did you try?
What concepts are you missing?

Did you already look into slicing / getting element from a list?
That will be what you need in the end.

You can easily get a character from a string like this

a = "some random string"

strings are immutable in python, meaning you will need to create a new string.