Learn Python Programming - 27 - Last Letter of String (Exercise)

Hey Guys! This is Kazi from Clever Programmer Calm, where you learn to code smarter. So, let's get started. I want to cover last letter of a string function in this video. Okay, so how do we play around with the string so we can get its last letter? That's the function I want you to write. Should be very simple. You should be able to get it pretty fast if you look at the tests below. If you use the last letter function, pass it "hello" with the summation mark; it should give you this LeMay shin mark. If you give it "banana"; it should give you an A because A in this case is the last letter. If you give it something with only one letter; it should return that letter. If you give it again, funny guys, s; you get the idea.

So, let's code this bad boy up again. You do not deserve to view the solution if you haven't participated and try to do it on your own. This is you got to be part of actively learning okay. I don't want you to be passively learning like you're sitting back like eating some popcorn. I don't want you to do that. While I do agree this is kind of like Netflix for your career, but I still want you to be actively learning. Okay? It's like Netflix that you engage and participate. Alright, so let's get to coding this bad boy up.

Notes:

----------------

* Define last letter

* It takes in some string. You can literally call it a string if you want to, but we're just going to call it "strength".

* What does it do? Well, it's very simple. It returns the last letter.

* How do you return the last letter?

* If I opened up a terminal and showed you guys how does bad boy works quite simple. If I have a string like "hello" too; it's second letter I would do this to get its third letter. I'd do that to get its first letter. I'd do this but if I wanted to get its last letter, there's a trick in Python that you can do index by negative numbers.

Let's code this up

------------------

Return string and last letter. Okay, as simple as that. Let's test our function and prove to ourselves that we are indeed correct. And it says your code is correct okay. That's it for this video if you washed up to this point and you haven't subscribed subscribed right now because you don't want to miss the next videos I will see you there. It didn't end.

Let's try it again

--------------------

Hey guys! This is Kazi from Clever Programmer Calm, where you learn to code smarter. So, let's get started. I want to cover last letter of a string function in this video. Okay, so how do we play around with the string so we can get its last letter? That's the function I want you to write. Should be very simple. You should be able to get it pretty fast if you look at the tests below.

Exercise Problem

-----------------

* Define last letter

* It takes in some string. You can literally call it a string if you want to, but we're just going to call it "strength".

* What does it do? Well, it's very simple. It returns the last letter.

* How do you return the last letter?

* If I opened up a terminal and showed you guys how does bad boy works quite simple. If I have a string like "hello" too; it's second letter I would do this to get its third letter. I'd do that to get its first letter. I'd do this but if I wanted to get its last letter, there's a trick in Python that you can do index by negative numbers.

Solution:

-------------

* Return string and last letter

* Okay, as simple as that

"WEBVTTKind: captionsLanguage: enhey guys this is Kazi from clever programmer calm where you learn to code smarter so let's get started I want to cover last letter of a string function in this video okay so how do we play around with the string so we can get its last letter that's the function I want you to write should be very simple you should be able to get it pretty fast if you look at the tests below if you use the last letter function pass it hello with the summation mark it should give you this LeMay shin mark if you give it banana it should give you an A because a in this case is the last letter if you give it something with only one letter it should return that letter if you give it again funny guys s you get the idea so let's code this bad boy up again you do not deserve to view the solution if you haven't participated and try to do it on your own this is you got to be part of actively learning ok I don't want you to be passively learning like you're sitting back like eating some popcorn I don't want you to do that ok while I do agree this is kind of like Netflix for your career but I still want you to be actively learning ok it's like Netflix that you engage and participate it alright so let's get to coding this bad boy up notes or below solution notes or below exercise problem is below everything is there let's keep going define last letter ok now what does it take in it takes in some string so you can literally call it some string if you want to but we're just going to call it strength what does it do then well it's very simple it returns the last letter how do you return the last letter if I opened up a terminal and showed you guys how does bad boy works quite simple if I have a string like hello too it's second letter I would do this to get its third letter I'd do that to get its first letter I'd do this but if I wanted to get its last letter there's a trick in Python that you can do index by negative numbers if I do negative two this gives me the second-to-last letter which means I'm going to get the second L okay he'll last L of the word hell but if I want to get the last letter well I can just do this right it gives me the last letter now let's code this up return string and last letter okay as simple as that let's test our function and prove to ourselves that we are indeed correct and it says your code is correct okay that's it for this video if you washed up to this point and you haven't subscribed subscribed right now because you don't want to miss the next videos I will see you there it didn't end let's try it againhey guys this is Kazi from clever programmer calm where you learn to code smarter so let's get started I want to cover last letter of a string function in this video okay so how do we play around with the string so we can get its last letter that's the function I want you to write should be very simple you should be able to get it pretty fast if you look at the tests below if you use the last letter function pass it hello with the summation mark it should give you this LeMay shin mark if you give it banana it should give you an A because a in this case is the last letter if you give it something with only one letter it should return that letter if you give it again funny guys s you get the idea so let's code this bad boy up again you do not deserve to view the solution if you haven't participated and try to do it on your own this is you got to be part of actively learning ok I don't want you to be passively learning like you're sitting back like eating some popcorn I don't want you to do that ok while I do agree this is kind of like Netflix for your career but I still want you to be actively learning ok it's like Netflix that you engage and participate it alright so let's get to coding this bad boy up notes or below solution notes or below exercise problem is below everything is there let's keep going define last letter ok now what does it take in it takes in some string so you can literally call it some string if you want to but we're just going to call it strength what does it do then well it's very simple it returns the last letter how do you return the last letter if I opened up a terminal and showed you guys how does bad boy works quite simple if I have a string like hello too it's second letter I would do this to get its third letter I'd do that to get its first letter I'd do this but if I wanted to get its last letter there's a trick in Python that you can do index by negative numbers if I do negative two this gives me the second-to-last letter which means I'm going to get the second L okay he'll last L of the word hell but if I want to get the last letter well I can just do this right it gives me the last letter now let's code this up return string and last letter okay as simple as that let's test our function and prove to ourselves that we are indeed correct and it says your code is correct okay that's it for this video if you washed up to this point and you haven't subscribed subscribed right now because you don't want to miss the next videos I will see you there it didn't end let's try it again\n"