So let's solve the next question.
It is regarding a Caesar cipher is a simple substitution cipher in which each letter of the plaintext
is substituted with a letter found by moving in places down the alphabet.
So, for example, let's assume the input plain text as B, C, D, X, Y or Z.
So we've shifted by invisible to food.
Let's see what you find is equal before then will be changed to e b will be changed to f, c will be
changed to G.
They will be changed to H.
I'm sure.
And you'll excuse me change to be y to see that 2D.
So here and will be the value which will be provided separately.
I think so.
I guess here is to write a function that accepts the argument.
One is the text, which is something like this, and another value, a number by which the letters need
to be shifted.
That is in here.
Now, this function will return an encrypted string.
Will all the letters transform from this form to this function, while all the punctuations and white
spaces will remain unchanged?
So try this out.
And you can pause the video now and unpause in case you want to see the solution for them.
Now, let's go ahead and that's why I've been in problem.
So this is a string related problems.
So for this, we will need to import those drinks library.
So let's say import strength as s d.
I am strength or let me make this next in String's Library, we already have letters which are already
present in lowercase and a book bookcase fought so we can download the ones, so we can simply say letters
is equal.
Those green dot sky underscored lowercase.
Let's see, what do we have in letters?
So here we have all the letters in lowercase.
Now let's get the number in.
So let's get the number in as an input now.
And we're getting it as an input.
We need to convert it into integer also.
So we say in
input and insight input, we say how many shifts?
And the person can enter the number of ships they want.
Now we need to shift.
Each and every year.
So let's try to create something as shifted here.
So we create another list with shifting regulators.
So let's see.
Shifted and shifted will be equal to now.
What will we have in shifted?
So inch of third, we will have a BKD.
So let's say there are a number of the number of letters which we have shifted by four.
So when we shift by four.
Then we show these by fall, we will have these letters, as it does, but they will be shifted in the
list.
So the index will be a little different.
So what can we do is we can create the list by letters and in letters.
We will get only the values which will be having, let's say, shifted by.
And so we can simply say we want the letters to start from in and hope delivery.
What do we get here?
Let's shift it and let's practice.
So let's step four.
So it gives me these shuffled ones.
Now then we try to map these.
So Z will be mapping of some other character.
But the last few characters are still missing their mappings.
So for that or let me print it for you.
Let's print that for, you know, let's say four.
So you can see this one is shorter than this one.
So what if we have F E for B?
We have F for C, we have T.
But we do not have anything for WXYZ.
So for that, we need to add these characters in the at the end so we can do that by simply adding letters
from the very beginning, still in in time.
So let's see.
What do we get?
That's a fourth.
So here you can see this is this mapping which we have got.
This is the mapping which we have generated.
So when we say for ship, it will replace this by this, this by this.
Now, below, we have created what the sequence should be, but we have still not told that whenever
you find a replaceability, that is still not been done.
So for that, actually, we have to create a map function.
So what the mapper does is it will basically map those values to each other.
So let's create the map of function here.
So we say map book equals.
It's a dictionary.
So we are creating a dictionary in the dictionary.
What do we have?
We have letters.
And in the letters, we take index.
And with it, we say shifted and index.
I for I in range of all letters.
What it simply does is its print map.
So for each and every character, you have created a mapping.
Right now, what we need to do further is let's say we have any text, OK?
Let's say we have a text is going to do this.
Before the
door was saying, OK,
this is a decent sentence.
Now, if you want to transform it, we can simply say so here we get each and every alphabet.
Now, I want to get alphabet from the map itself.
So I will t or let's get the alphabet one by one.
Now, if the map is present.
In my book, Dark Keys.
Then it should return my bush.
It's like if it is not present, is it should simply read-only as hazardous.
So this is what we have now, this still needs to be converted into a sentence full so we can simply
say
not join join me to break it.
So let's run this.
So what it simply did is it converted it and joined.
What have we done?
We have simply created a map, but then we have created a dictionary, kind of all of what needs to
be converted to what.
Then we check if the character which we are looking for is present in the map or the keys.
Then we simply put the map.
But here, if it is not there, then we put the alphabet.
So wherever we have these exclamation marks or those pieces, they will be one thing as it is.
Otherwise, it will try to insert the map or key that because it will try to insert the value of the
map.
That's it.
So this is how we solve this particular problem.
And then you can convert it into a function or anything you want.
So that is something which you can do on top of this.