Coming back to our actual program, let us go to our Demo Morton now here we have defined the main function
that we set, the values of the variables.
My message, SDR and my guests, when they are called.
Now, the rest of the program will also have a function mean that is called at the start of each program.
The reason we are having a main function is explained at the end of when we conclude a particular session.
And over here we have the variables, my messages, a certain mixture which stores the plain text message
to encrypt and the key which is used to do the encryption.
Now, over here, we also have a variable ciphertext, ETR, which is an encrypted message by calling
the function that takes the argument.
So over here, this will be stored as an encrypted message that will come from the message or from the
function, encrypted messages to the code that does the actual encrypting is in the definition encrypted
message, Asgeir function, which is defined the later.
Now this function takes two arguments, an integer value for the key and a string value for the message
to encrypt.
So in this case, we have passed my messages and my estimate now when passing a multiple argument to
the function called separate the argument with the bombing that we have passed over here.
So the return value of the encrypt messages is a string value of an encrypted ciphertext, and this
is stored in the variable ciphertext SDR.
Now, the ciphertext e-mail still messages printed on the screen and copied to the clipboard.
When we say here, print and not copy.
Now the program prints up by character at the end of the message so that the user can see any empty
space characters at the end of the ciphertext.
After execution is done, the program execution's returns to the line after the line that is called
or call the particular main function.
So the key and the message variable between the parentheses or the parameters.
When we define the encrypt messages, it takes basically two arguments in this case, like the value
in Michael Asgeir and the messages to these values are assigned to the parameter key and the message
when the execution moves to the top of the function.
Now, you might wonder of how you need to have the key and the message parameter since you only have
a variables as my keister and my messages during the main function.
But we need different variables because the mike is different in my messages during the main function
at of local scope and cannot be used outside the particular main function.
Now when we come to the next, that is the list data type.
So over here, if you see we have created ciphertext SDR in the particular function by giving square
bracket single open, closed, multiplied by Kirsti.
Now, before we can move on, you need to understand how the list works and what do you get out of the
particular list.
List value can contain other values also similar to how string begin and end with a quote.
A list value begins with an open bracket and ends with a closed bracket and the value stored inside
the list are between the brackets.
So if more than one value is in the list, the values are separated by commas.
For example, if we want to see a list in action, we will enter something into the interactive shell
over here like we would give sea animals.
SDR is equal to we give sea dog got a horse elephant.
We have defined this.
Then here you just say in the next line, animals SDR, we get all the values.
Prenter So here the animals Asgeir that we have available store a list of values.
And in this list, values are basically four strings that we have created.
So over here, the four string values are stored individually there.
So the individual value inside the list is also called as an item or an element.
No list are ideal to use.
Then you have to store multiple values in one variable for many of the operations you can do with strings.
Also work with list, for example, indexing or slicing Volks on list values the same way that works
on this string values instead of individual characters in a particular string, the index refers to
an item in a particular list.
For example, if we say here, see animals SDR Index zero, we get the default index or if we see animals
SDR Index two, we get there.
The third item apart in the particular list, or if we see animals SDR in brackets one column three,
we get that value for.
One, bill, three.
So keep in mind that the forced index is zero and not one so similar to how you use liasing with a string
gives you a new string, and that is a part of the original strength.
Using Fleisig with list gives you a list that is a part of the original list.
And also remember that if a slice has a second indexed, life only goes up to but doesn't include the
item at the second index.
Now you can also use a for loop for iterating over values in the list, just like we can.
I trade over characters in a particular string.
For example, if you say for S1 in again we use on our list.
So we give some again the same values comma clause it open this column and here we give Ziprin for the
know we are cooking, plus the value of S1.
And so we get for dinner, we are cooking dog got hot, so everywhere this value of one is automatically
replaced and that is what is printed.
So each time your loop is iterating, the S1 variable is assigned a new value from the list, starting
with the list zero index until the end of the particular list.
You can also reassign the items in the list.
Now, for example, say here, as we have defined animala steerable, let's define that again.
Animals Asscher is equal to give.
There again the same items.
We have defined this now we say here animals SDR at the index.
Do we want to make there something like nine nine nine nine and now we see animals osteotomy are to
be printed.
So now we have replaced that value to modify an element or third element of the particular list.
We have used the index to get the total value with using animal instead of the index two and then use
an assignment statement to change its value from the original one to a new value.
So when we check the content of the list again now the earlier animal resource horse is no longer existing
in a particular given list.
Now, similar to this, how can you have list of let's list values can even contain other list values.
For example, let's create list one here is equal to recreate, say, dog cat one and it give a comma.
Next we have the number one three five, for example, and then close it.
Now if we see list one, index zero, we get the first list.
If we say list one zero zero, we get the full stroke, first column value.
Similarly, if we say list one says zero one, we get the next value.
If we say list one second row, first column, we get the value one.
Similarly, list one, one one.
Or if you want to it, say list one, one, two, because that is having one more value inside it.
So here the value of the list, one evaluates to the list that is dog at first, which has its own indexes.
The double index brackets over here, that is, we have use list one zero zero indicate that we are
taking the first item from the first list.
If we only say list zero, it evaluates to the whole of the first list.
And if we see list one in the index zero zero, it goes to the first value in the first list.
That is dog.
Similarly, you can also use the length and the operator with the list.
Now you have also used the length method, which is there to indicate a number of characters in a particular
strip.
The length function also walks on list values and returns an integer of the number of list or items
in a particular list.
For example, if we see we animal length of C animals.
SDR, may the lenders for similarly, you have also used the in and not in operators to indicate whether
a string exists inside another string values.
The end operator also looks for checking whether a value exist in a list and they not in operator checks
whether a value does not exist in the particular list.
Now, for example, if we try to see value, say, log in any Nestea, we get the value to.
If we say dog sorry, in string dog one in animal Asscher, that is coming to Foote's.
Similarly, if we see a dog one say not in any Melissia comes through.
Right.
This is all we can use the particular values there.
So now coming to the list, concatenation and replication with plus and the multiplication operators'.
Now you know that the plus and the multiplication operators can concatenate and replicate the strings.
Same operators can also concatenate and replicate your list now, for example, of something into the
interactive schill c v right down here, C Python.
And plus again here we enter C hacking together python hacking.
OK, similarly, if we see Python multiplied by five, we get five times Python Prenter.
Now that's enough about the similarities that we have seen between strings and this almost whatever
we can work on string, we can also work it on the list.
So just remember the most operations you can do with string values.
Also work with your list of values.