The transposition cipher uses an integer for a key which is stored in your Michy Istar variable, and
the program accepts the more ETR variable which will store either in or decrypt to tell it to encrypt
or decrypt the file input namaskar fine.
But before we can read from the input finally Mystere, we need to check that it exist using the OS
dot but not exist.
So coming to checking whether a fire is existing, we are reading files is always harmless, but you
need to be careful when writing to the files.
So calling the open function in the right mode on a file name that already exist overrides the original
content.
So using the OS dot, dot, dot exist function in your program can check whether or not that file already
exist, not understanding the overstored part, the DOT exist function.
It takes a single string argument for a file name or a part or to a file and returns.
True, if the file already exist and falls.
If it doesn't, the always path don't exist function exist inside the part module which exists inside
the OS module.
So when we import the module, the path module is important also.
So for example, if we just go to our interactive shell and here if we try to enter the same import
OS first, then we say always stored but not exist.
And here we give say ABC Dot, the 60 in the bracket.
We get the value through.
If we try to say overstored but not exist in bracket, we give your face equal numbers, then Windows
CE System 32, then calc dot.
Except for example, we get it through.
Suppose you are not on Windows your own Mac OS, then you will have to write down something like No,
I will execute this, but just showing you how the command would look like it will be slash, say USCIRF,
then say local, then say Binn and then say, oh, fine name, which is there for Mac OS.
And if you're on Linux then you will have to write down, say, user slash bin and slash the fine.
That's how you can check the path existing on all the given operating systems now.
In the particular example that we have checked for the function, it confirms that the TalkTalk file
is there in Windows.
Of course, you will only get the results if you are running Python on Windows.
Now, remember to escape the backslash in the Windows file part by typing another backslash before it.
If you're using Mac OS, only the Mac OS example will return to no.
Coming back, we will check whether the input file exist with the oyster or part does not exist function.
So when we are using this in our Demo 17 file to check whether the filename in the input file name is
still exist, otherwise we have no file to encrypt or to decrypt it.
So if we say if not always dot, dot, dot, exist the input, find the Mystere, then we are printing
a message that is the file.
The name does not exist, giving quiting and parsing that the input filename.
So if the file doesn't exist, we display a message to the user and then with the particular program
next, we are using the string methods to make user input more flexible.
Now next, the program checks here whether a file with the same name as the output filename exist,
and if so, it asks the user to type see if they want to continue running the program or to quit the
program now because the user might type various responses, like a small C, a capital C or even the
word continue with C capital.
We want to make sure that the program will accept all of these versions.
To do this, we are basically using more string methods here.
That is upper lower title string methods.
So that is over here that we're checking out.
So the upper and lower string methods will return the string.
They are called on in an upper case or lower case letters respectively, and enter the following into
the interactive shell to see how the methods basically work on the same string.
So, for example, if we go back to the python shell here and we try to enter, say, Python, Doc Apple,
we get that all in the uppercase or we try to enter Python doc level, we get all in the lowercase.
Now, just as the lower and the upper string methods return a string and lowercase or uppercase, the
title string method returns string in the title keys title cases where the first character of every
word is uppercase and the rest of the characters are in the lowercase.
For example, if we enter something like Python Dot type it, we get it.
First character in upo dressed all in small.
Similarly, if you enter everything in some capital and still you title, it will be converted in the
same manner.
Or if you have, say, python hacking goes beginner level everything you'll want to convert to type
them.
So every word, the first character will be in capital.
So we are using title a little later in the session to format messages we output for the user.
Now on we would be coming with first as the using this starts with and the ends with string methods.
So this start with method returns.
True, if it's string argument is found at the beginning of the string, for example, if we see Python
then thought starts with and here we give capital P for example, we get the values through, or in
that case we see Python starts with and we give here.
I get the values Foote's for this case.
You can also take a variable, for example, C John is the value in the variable and we use this variable
that starts with and we give your up.
Still, the value would be true.
So this starts with method is case sensitive and can also be used on strings with multiple characters.
Similarly, we have the ends with string method, which is used to check whether a string value ends
with another specified string value.
For example, if we say here, python hacking dot C ends with in brackets, we give hacking.
It is true.
Or if we try to say again in single code five ten hacking ends would give your ex capital list everything.
Same at this for.
So the string values must match perfectly.
Notice that the lack of exclamation mark or your capital letters will also cause an injury to return
value as Foote's now will come to using these string methods in our program.
So now let us go back to the more 17.
As noted, we want the program to accept any response that starts with a capital C, regardless of capitalization.
So this means that we want the file to be overridden.
Whether the user types moisy continue in small C capital or another string that begins with C Soulsville
use the string methods lower, starts to make the program more flexible when taking the user input.
So over here, when we are checking over here, if the Oyster Bar don't exist, the output filename
is still reprint.
This will be overridden.
Type C or Q4 quick and then reticular.
The response saying response SDR is equal to input and use that the more than sine, if not response
total overall starts with C, then you exit.
So over here we are taking the first letter of the string and check whether at this C using this starts
with method, starts with method that is used in case sensitive and checks for a Lawsie.
So we have used a lower method to modify the response of the string capitalization to always be in the
lowercase.
So if the user didn't enter a response starting with C, then this starts with would return for it's
not otherwise which will make the if statement to evaluate to true, because if not in the if statement,
this is what it is called to end the program.
So technically the user doesn't have to enter.
Q Two quick.
Any string that doesn't begin with C causes the system exists function to be called and with the program.
That's it from the session.
Thank you very much.