osdir.com


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

Python string with character exchange


Thanks Reto. I got it now. Matt

On Sun, Jul 14, 2019 at 2:26 PM Reto <reto at labrat.space> wrote:

> 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"
> print(a[0])
> ```
>
> strings are immutable in python, meaning you will need to create a new
> string.
>


-- 
Cheers,

Matt Zand
Cell: 202-420-9192
Work: 240-200-6131
High School Technology Services <https://myhsts.org/>
DC Web Makers <https://dcwebmakers.com/>
Coding Bootcamps <https://coding-bootcamps.com/>